[OT] Perl woes

breno breno at rio.pm.org
Thu Jan 29 01:38:58 GMT 2009


On Wed, Jan 28, 2009 at 11:05 AM, Andy Armstrong <andy at hexten.net> wrote:
> On 28 Jan 2009, at 12:30, Jonathan Kimmitt wrote:
>>
>> Most people on this list seem to defend the perl design decision such
>> that
>>
>> if ($item == "xyzzy")
>>
>> should only emit a warning, because after all, a string can be converted
>> to a number with no loss of meaning (!).
>>
>> However, what about this one:
>>
>> for (my $i==0; $i<($tbl_width - 1); $i++) { .... }
>>
>> Is anybody seriously arguing this could possibly do anything useful. Yet
>> it
>> is not trapped out as an error unless you add the obscure syntax:
>>
>> use warnings FATAL => 'all';
>
>
> It throws a warning with 'use warnings' - which is not at all obscure. Would
> you compile C with warnings turned off?
>

My gcc would not catch it otherwise:

   $ cat for.c
   #include <stdio.h>
   int main (void) {
       int i, tbl_width = 3;
       for (i == 0; i < (tbl_width - 1); i++) {
           printf("hello\n");
       }
       return 0;
   }
   $ gcc -o for for.c
   $ ./for
   $ gcc -Wall -o for for.c
   for.c: In function 'main':
   for.c:4: warning: statement with no effect
   $

but I also think the author's point might be compile x runtime. On
'==' x '=', one could argue that true/false might also be used as a
begin statement for a 'for' loop :-)


Cheers,

-b


More information about the london.pm mailing list