After a 18-hours hacking run, I fixed all three blocking issues today.
Thanks to generous help from Leo and #parrot folks, Pugs now generates correct PIR; the parrotBrokenXXX global flag we used to dodge around register alligators is finally gone. Hurray for a new dawn of non-scheduled Parrot!
The lexical pad spec proved to be quite sane and easy to target, except for the somewhat irritating demand of having to manually initialize lambda lifted closures, even for package-scoped subroutines. For example, this Perl 6 code:
my $x;
sub f { $x++ }
f();
becomes this PIR code (you can try it out with "./pugs -CPIR test.p6"):
.sub "main" :anon
.local pmc s__x
.lex "$x", s__x
$P8 = find_name "&f"
$P8 = newclosure $P8
store_global "main", "&f", $P8
# ...
.end
.sub "&f" :outer("main")
# ...
.end
Running newclosure for each subroutine at runtime is quite silly, because its outer subroutine "main" cannot be entered again. Moreover, it prevents code in BEGIN and other packages from calling &f using fully qualified syntax.
It would be nice if the newclosure can be performed at compile time, e.g.:
.sub "main" :anon
.local pmc s__x
.lex "$x", s__x
.end
.sub "&f" :outer("main") :closure
# ...&f is initialized automatically to see "$x"
.end
Leo suggested me to write this request up and post it to p6i, so here it is. :-)
Comments