On Sat, Aug 20, 2005 at 10:33:03PM +0000, Ingo Blechschmidt wrote: : Hi, : : S02 says: : our $a; say $::("a"); # works : : my $a; say $::("a"); # dies, you should use: : my $a; say $::("MY::a"); # works
That looks like somebody's relic of Perl 5 thinking. Personally, I don't see why the second one should die. I was kind of hoping that symbolic lookups would include lexicals in Perl 6, unlike in Perl 5. Then you use MY or OUR to force it one way or the other. An unqualified lookup should find exactly the same symbol at run-time that the compiler would find at compile time (though with non-strict semantics on undeclared globals regardless of lexical strictness, since the whole point of differentiating $::() notation from ${} notation is to get rid of "use strict refs"). Also remember that leading :: in general doesn't imply "main" as it does in Perl 5. : How can I use symbolic dereferentiation to get $?SELF, $?CLASS, : ::?CLASS, %MY::, etc.? : : say $::('$?SELF'); # does this work? Probably not, since the ::() notation doesn't want sigils in the key, and you have to say $?::('SELF') to have any hope of it working. On the other hand %MY::<$?SELF> might get you the symbol out of the symbol table hash, unless $?SELF is too macro-y for that. $? variables aren't required to have a dynamically lookupable meaning at run time, since their native dynamic context is the compiler, not the run-time. : say $::('MY::$?SELF'); # or this? No, we don't currently allow sigils after ::. But maybe we could have some quoting mechanism to allow it: say $::('MY::<$?SELF>'); # or this? : Also, is $::! valid syntax? (Or am I required to write this as : $::("!")?) I suspect :: after a sigil is always a no-op unless it's followed by parens (and maybe <>, if we allow sigil lowering, which would also give us: $OUTER::OUTER::<$_> and such.) I think I like the option lowering the sigil to the key. Maybe the outer sigil is meaningless in that case, and it's just OUTER::OUTER::<$_> But if we say that any package/type name can tagmemically function as a hash if you use like one, then the last :: can go too: OUTER::OUTER<$_> OUTER::OUTER{'$_'} Though we're getting close to confusing this notation with %OUTER::OUTER::{'$_'} which looks similar, but (if we take the Perl 5 meaning) doesn't do :: splitting on the key. In other words, this would also get to OUTER::OUTER<$_>: OUTER{'$OUTER::_'} because it's accessing through the package as a hash and does further :: breakdown. But this wouldn't work: %OUTER::{'$OUTER::_'} because it's accessing through the actual symbol table hash, which doesn't have any such symbol as one of its keys. That's an awfully subtle distinction, though. I think OUTER::OUTER's symbol table hash needs a better name than %OUTER::OUTER. Maybe it's named OUTER::OUTER<%OUR> or OUTER::OUTER::<%MY> or some such. Which makes me think that Perl 5's %FOO::{'name'} symbol table notation is really bogus, because %OUTER:: doesn't really refer to a single symbol table in Perl 6, but the starting place for a symbol search that may span several symbol tables. At least, that's how I've been thinking of it. Maybe we nail OUTER down to one MY and just use OUTER.findsym('$x') if that's what we mean. But then we get bad interactions if someone says FOO.findsym('$x') on a class that defines its own findsym method. Or maybe that's a feature. Or maybe only pseudo classes that resolve to MY variants have a findsym method. ENOCAFFEINE. Larry