On Thu, Feb 28, 2008 at 01:21:40PM +0100, Klaas-Jan Stol wrote: > hi, > > recently on #parrot there was a short discussion on symbol handling > w.r.t. nested scopes. > > During that discussion, I understood that when looking for a symbol in > a PAST::Block node, it will look in that block, and, if not found, in > any :outer blocks. > ... > When looking at the actual implementation of the symbol() method on > PAST::Block (which does symbol storing and retrieving), > there is no proof of such behavior. > ...
It's not the symbol() method in PAST::Block that does this, but the 'scope' method of PAST::Compiler. See line ~1048 of compilers/pct/src/PAST/Compiler.pir . When processing a PAST::Var node that doesn't provide its own 'scope' attribute, the PAST compiler starts looking outward through the current set of enclosing blocks for any block that has an entry in its symbol table matching the name of the PAST::Var node and a corresponding 'scope' attribute. It then uses the first such scope found. Pm
