Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pmichaud (6013)

pmichaud
  (email not shown publicly)
http://www.pmichaud.com/

Patrick Michaud is the pumpking for the Rakudo Perl 6 compiler. He holds a Ph.D. in Computer Science and was formerly a Professor of Computer Science at Texas A&M University-Corpus Christi. He is currently a software developer and consultant focused on open source development and applications, including Perl, PmWiki, and Linux.

Journal of pmichaud (6013)

Thursday December 04, 2008
03:18 PM

Rakudo now supports inline PIR

[ #38022 ]

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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.