On Nov 22, 2005, at 18:32, Chip Salzenberg wrote:
OTOH, that same case in Perl 6 is a normal closure and is supported
with
the default LexPad:
Ok. I'll change implementation accordingly. Below is the full code of
case 1 / outer.pir
leo
.pragma n_operators 1 # add creates new PMC result below
.sub do_add3
.param pmc arg # looks nicer than get_params
.lex '$a', arg
.lex '&add3', $P1
.const .Sub add3 = "add3"
$P1 = newclosure add3
$P2 = $P1() # tailcall eventually - b0rked
.return ($P2)
.end
.sub add3 :anon :outer(do_add3) :lex
$P0 = find_lex '$a'
$P1 = $P0 + 3 # create/return new value
.return ($P1)
.end
.sub main :main
$P0 = do_add3(20)
print $P0
print "\n"
$P1 = do_add3(21)
print $P1
print "\n"
.end