Rakudo now supports inline PIR

pmichaud on 2008-12-04T20:18:24

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. Register numbers higher than 9 run the risk of conflicting with automatically-generated registers generated by PCT. One can also declare local symbols, but may need to be careful not to conflict with any local symbols generated by PCT (those are somewhat rare, however).

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