> Take PHP and Python, for example.
> 
> 
> > >     my $a, $b, $c;            # only $a is lexically scoped
> > RTFM.
> > >     my ($a) = <FHANDLE>;      # after deducing (by the above) . . .
> > >                               # when I wanted only the first line.
> > Silly beginner gotchas.  It's not an inconsistency of the
> > language by any means.
> >
> 
> Yeah. Beginners. I was one too. And I remember always falling on these...
> But that's OK, since we probably don't want any new Perl programmers...

I agree. I hate these gotchas. They cost a *lot* of problems when I'm trying
to explain things.

> Tell me one. I couldn't find it.

The main problem I see is cross checking. I *like* having to declare things as
'my' - it catches my errors for me:

my $variable;

$varaible = 1; # mis-spelled - caught by 'use strict'.

If you had this 'use scope' pragma, this auto-error checking would be 
compromised severely.

However, that still doesn't get rid of the gotchas - personally I think that:

my $a, $b, $c;

should be an error, a warning, or DWIM. Especially: 

my $a, $b; 

which is particularly insidious because $a and $b are default globals. Yuck.
As should:

my ($a) = <STDIN>;

I'm also fond of making 'use strict' and '-w' ON by default, and turned off by
pragma. But that's just me.

Is there a 'annoying beginner mistakes and what the $!#$@ to do about them RFC'?
If not, it might be a worthwhile thing to put together.

Ed

Reply via email to