Re: Symbol table lookup and hash

2005-03-17 Thread Larry Wall
On Thu, Mar 17, 2005 at 10:33:42AM +0200, Gaal Yahas wrote:
: I'm looking to understand symbol tables and the symtable hash better.
: 
: What's the motivation for ::() syntax? Is it mainly for binding aliases?

It's for explicit symbolic reference.  The ${...} syntax is now
entirely reserved for hard references only.

: How would $::("MY::bar") behave when my $bar has not been declared?

Would be undefined as an rvalue, and either legal or illegal as an lvalue
depending on whether the lexical scope in question is still being compiled.
(Modifications to a lexical symbol table are banned after the lexical scope
is done compiling.)

: (Similarly, what happens with an undeclared $::("Foo::bar") ?)

Almost exactly the same thing as Perl 5 would do with ${"Foo::Bar"}, except
there might be a search outward for all scopes containing a Foo subpackage,
which ends up finding the global Foo package by default.  In Perl 6 you
use a "*" when you absolutely want to start looking at the root, much like
Unix filenames starting with '/'.

: If I do the analogous thing with the symbol table hash, (how) is the
: behavior any different? What can you express with ::() but not with the
: symtable hash?

The only difference is that ::() will parse its argument for "::" and
potentially traverse multiple nested symbol tables, whereas accessing
the symbol table hash directly will assume you're only giving the
exact key for the hash and not look for "::".  Also, the sigils on
::() are outside ("@::($foo)"), whereas sigils in the symbol table
are part of the key name ("%::{'@' . $foo}").  But once you get to
the container object in question, it's the same either way.

Larry


Symbol table lookup and hash

2005-03-17 Thread Gaal Yahas
I'm looking to understand symbol tables and the symtable hash better.

What's the motivation for ::() syntax? Is it mainly for binding aliases?
How would $::("MY::bar") behave when my $bar has not been declared?
(Similarly, what happens with an undeclared $::("Foo::bar") ?)

If I do the analogous thing with the symbol table hash, (how) is the
behavior any different? What can you express with ::() but not with the
symtable hash?

-- 
Gaal Yahas <[EMAIL PROTECTED]>
http://gaal.livejournal.com/