On Wed, Jul 13, 2005 at 08:33:12PM -0400, [EMAIL PROTECTED] wrote: > On Wed, Jul 13, 2005 at 04:29:53PM -0700, Michael G Schwern wrote: > > I don't see the utility of the current behavior, except maybe it was easier > > to implement, and IMHO its ripe for mistakes like the one pointed out > > earlier: > > use strict; > > package Foo; > > our @ISA = qw(Foo); > > package Bar; > > @ISA = qw(Baz); > > print @ISA; # Hmm, everything looks ok. > > print @Foo::ISA; # SURPRISE! > > print @Bar::ISA; > > No warnings issued and strict won't save you. > > 1) Fix @ISA, or
What @ISA breakage does the above demonstrate? > 2) Introduce real package scopes: We already basically have them. { package Foo; our @ISA = ... ... } Folks don't like em. It sucks to have to indent an entire package. Same reason you'll almost always see: <html> <head> <title>foo</title> </head> <body> <p>This is in the body. <ul> <li>only now do we indent </ul> </body> Of course this doesn't stop you from doing: { package Foo; ... } but nobody seems to do that. > our() was never a problem for me, and if it is changed, some of my code > may break. I always prefer lexicals over global variables. > > Consider code like: > > our($MY_GLOBAL); > > ... > { > package SOME_OTHER_PACKAGE; > $MY_GLOBAL = $VAR_FROM_OTHER_PACKAGE; > ... > }; The feared Club of Backwards Compatibility! Curses! FWIW I wouldn't do that because it makes noticing that $MY_GLOBAL is not actually a variable in SOME_OTHER_PACKAGE difficult to spot. package Bar; ...a bunch of code... package Foo; $Variable = 42; $Foo::Variable or $Bar::Variable? Is that $Foo::Variable or $Bar::Variable introduced via an earlier our? You can't tell without examining all the preceding code throwing out part of the point of lexicals and packages: limiting scope. It doesn't follow the normal $Global, $lexical conventions. If SOME_OTHER_PACKAGE really needs to access another package's globals its better to be explcit about it and say $PACKAGE::MY_GLOBAL. Unfortunately these arguments appear to be a few years too late. I even tried going back in my time machine to try and change the behavior or our() before it was implemented but I found that no matter what I did I was unable to alter the implementation. :( http://www.newscientist.com/article.ns?id=dn7535 -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern ROCKS FALL! EVERYONE DIES! http://www.somethingpositive.net/sp05032002.shtml