Rod Adams writes:
> Considering that "proper" and common usage, not to mention strictures,
> dictates a heavy insistence on 'my'. I will thus assume that creation
> of lexical variables with 'my' far out numbers the creation of package
> space globals. Should we not then have it where it's the default
> behavior, and creation of package ones take explicit declaration (via
> 'our')?

Larry has addressed this before, coining "I made 'my' short for a
reason".  Python and Ruby both autodeclare in the lexical scope like
this, and some people like that.  Sometimes you see bogus assignments
in those languages just to declare a variable in an outer scope.

Also, the idea is a bit brittle in the face of large subs.  If you
change the control flow a little bit, you might accidentally change a
variable's scope, and then what you thought was one variable just became
two distinct lexicals.

There are pros and cons, and it basically ends up being a design choice.

> Well, at least when strictures are on. When they are off, the coder is 
> obviously playing fast and loose, and should get the easy 'everything 
> global' behavior.

When strictures are on, the compiler ought to die if you're tyring to
use a variable without declaration.  This is another reason why Perl
doesn't like autodeclaration.

Luke

Reply via email to