in reply to Doubly-nested deeply bound variable is undefined

The code also works if you remove the braces enclosing the $x and "sub foo" declarations.

This leads me to the following hypothesis:
The block enclosing the $x and "sub foo" declarations does not get invoked/executed, since it is just a block declaration. When you call foo(), just the sub gets called - the enclosing block has not yet been invoked.

If you use $x within foo, I believe a JIT block invocation takes place to instantiate $x. If you don't use $x directly, an un-initialized $x gets passed to run_this().

I'll defer to more enlightened monks to elaborate on this theory, and comment on whether this is desirable behaviour.

     "A closed mouth gathers no feet." --Unknown

  • Comment on Re: Doubly-nested deeply bound variable is undefined