I haven't written PIR in a while, and I'm not terribly familiar with the new changes, but I'll make some guesses.
Klaas-Jan Stol writes: > function main() > > local p = 123; > local q = 345; > > foo(q); > foo(q); > > function foo(a) # nested function, it does have access to p in "main" > print(p); > p = p + p; > > print(typeof(a)); > print(a); > end > end > > I would translate this to this PIR code: > > .sub _main > new_pad 0 > > # local p = 123 > .local pmc p > p = new .PerlInt > p = 123 > store_lex 0, "p", p If I recall, store_lex 0 is meaningless, and you ought to be using either store_lex 1 or store_lex -1. Not too sure about this one though. > > # local q = 345 > .local pmc q > q = new .PerlInt > q = 345 > store_lex 0, "q", q > > newsub $P0, .Closure, _foo > > # foo(q) > .arg q > $P0() Shouldn't this be: $P0(q) ? And likewise below? > > # foo(q) > .arg q > $P0() > > end > .end > > .sub _foo > .param pmc a > > # print(p); > find_lex $P0, "p" > print $P0 > > # p = p + p; > $P0 = $P0 + $P0 I feel a little uneasy about this line. I'm not sure how PIR interprets this. > store_lex "p", $P0 > > # print(typeof(a)); > $S0 = typeof a > print $S0 # ???? > > # print(a); > print a # ERROR! > .end > > My problem with the last 2 statements is: > - the statement print(typeof(a)); print "SArray", which I don't understand. I'm going to guess that that's due to your use of .arg above. Luke