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 November 13, 2008
05:45 PM

The world according to .PARROT

[ #37870 ]

In Rakudo we have a number of places where bits of Parrot poke out from underneath the covers at inconvenient times; masak, moritz, and chrisdolan have been particularly good at finding these, especially when dealing with strings in Rakudo.

When we get HLL mapping fully working in Rakudo then a lot of these will go away; in the meantime I've been trying to explain what's happening "behind the scenes" that cause the seemingly bizarre behaviors. But yesterday I decided it would be better to provide a way to remove the covers entirely...

So, Rakudo now has a .PARROT method that reports the underlying Parrot data type for an object. This is in contrast to .WHAT, which gives back the (sometimes imperfect) Perl 6 view of an object.

Here's an example involving %*ENV -- normally we expect values in %*ENV to be (Perl6) Str objects, but the current implementation of %*ENV tends to give us String PMCs. But rakudo considers Parrot String and Perl 6 Str to have the same .WHAT protoobject, so it looks like it's a 'Str'.

        > say %*ENV; /home/pmichaud
        > say %*ENV.WHAT;
        Str

The new .PARROT method lets us view the true identity of an object:

        > say %*ENV.PARROT;
        String

This still doesn't fix the problem, but at least it gives some transparency into what's going on.

I also adjusted the value semantics for the String PMC so that it auto-promotes to a Perl 6 Str object whenever it's asked for its scalar value. That should make it easier to get things into the form needed to get work done, at least until we can complete our other transitions that make this more seamless.

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.