On Wed, Jul 09, 2008 at 04:46:19PM -0400, Bob Rogers wrote: Content-Description: message body text > In effect this is little different from having 'foo' as an immediate > block. If we now say that a newclosure op is required to invoke 'foo', > then that means that the 'foo()' HLL subroutine has to be generated as: > .local pmc $P0 > $P0 = find_name_not_null 'foo' > $P0 = newclosure $P0 > $P0() > . . . > > Not true. The compiler always knows when it's compiling a closure. So > if, at the point of definition, the emitted code does: > > foo_closure = newclosure foo_sub > set_hll_global 'foo', foo_closure > > then the compiler doesn't have to treat calls to "foo" specially.
...would we also have to generate code to restore the previous value of 'foo' upon exiting the sub? (Think recursive calls here.) sub bar($x) { sub foo() { say $x; } if ($x > 0) { bar($x-1); } foo(); } Pm