Steve Lukas skribis 2006-09-11  4:35 (-0700):
> "If you declare a lexical twice in the same scope, it is the same lexical"
> I would argue for: If you declare a lexical twice in the same scope,
> it is an error! 

I agree.

The reason that I love "my $foo" is that it always gives me a new
variable. I can safely use this anywhere in the code, without any need
to read all the existing code. This is, for me, one of the most
important aspects of having lexicals in the language: I can add
(debugging or otherwise temporary) code to any existing project without
getting to know the structure of the project's code.

Perl 5 warns that a second declaration masks the first. This is fine: it
tells me about the stupid mistake I made and lets me fix it. A
compile error would be fine too. In fact, even better because then my
probably broken code isn't executed then.

Just ignoring the declaration is bad, just like implicit declaration. If
we do this, we get only typo checking, and none of the other nice
protection that lexical declaration gives us.
korajn salutojn,

  juerd waalboer:  perl hacker  <[EMAIL PROTECTED]>  <>
  convolution:     ict solutions and consultancy <[EMAIL PROTECTED]>

Reply via email to