Rakudo now supports inline PIR
I've just added the capability to write inline PIR directly in Perl 6 subroutines in Rakudo Perl. This is done using the :PIR adverb on the 'q' quote operator, thus one can write:
q:PIR { say 'hello' }
and whatever is in the bracketing characters will be embedded "inline" with the surrounding Perl 6 code. The special %r placeholder can be used in the PIR to specify the return value of the PIR:
my $a = q:PIR { %r = box '123' };
say $a; # "123\n"
Within the PIR it's safe to use any of the PIR registers $P0..$P9, $S0..$S9, $I0..$I9, and $N0..$N9. One can also declare local symbols, but there's always the possibility of conflicting with a compiler-generated symbol (there aren't many of those, though).
Of course, we don't expect this to ever be a fixture of "true" Perl 6 programs -- this is just here to make it easier to write Perl 6 builtins for Rakudo (i.e., the "Prelude") and perhaps help others who are bootstrapping modules on Parrot. Ultimately the :PIR flag will only be available via an appropriate 'use PIR' statement or the like.
Also, the quote sequence will eventually become 'Q:PIR' with an uppercase 'Q', but a parser issue constrains us to stick with the lowercase 'q' for now.
More coming soon!
Pm
