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

Categories:

About this Entry

This page contains a single entry by pmichaud published on December 4, 2008 8:38 PM.

Better Diagnostics On Ambiguous Dispatch was the previous entry in this blog.

A First Cut On proto is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Subscribe

    Subscribe to rakudo.org

Powered by Movable Type 4.21-en
Technorati Profile