On Thu, Jun 21, 2001 at 01:56:31PM -0700, Randal L. Schwartz wrote:
> Ahh, I think I see the problem. The syntax for $foo actually means
> the variable $main::foo (when main is the current package), and
> $main::foo is a global variable, but $foo is a "local to the package"
> variable. So perlmod is arguing it from a syntax point of view, and
> I'm arguing it from a semantics point of view.
This syntax view is how my concept of packages has always worked.
$main::foo and $Foo::foo, despite being having the same name, foo, are in
seperate namespaces. I think you're approaching it as $main::foo and
$Foo::foo having different names entirely, with funny, but standard, ::
sequences in their names.
> perlmod jumps right to syntax, leading to people thinking there's a "MY
> package" which causes loud cognitive dissonance in my ears.
The problem with the concept of a "MY" package is it doesn't behave as every
other package in Perl behaves. You can't carry a package variable around in
a closure, you can't mask a package variable of the same name in nested
scope (syntactically it would appear that way with local, but it isn't
really), and you can access a package variable from an entirely seperate
scope (i.e. not a nested scope) from the one it was initialized in.
Due to the differences it would actually be more difficult to think of the
lexical scope as a package, because then you'd have to remember a bunch of
exceptions.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--