Skip navigation

Tag Archives: rakudo

I previously wrote about what I wanted out of the Parrot workshop. So, here’s what I actually got.

  • There are some amazingly smart people working on Parrot/Rakudo who really believe in the promise of both.
  • I need to actually start learning Perl 6. My wrote my first baby Perl 6 programs Saturday. It’s nice to have something that’s like (for some definition of “like”) Perl 5, but organized from the start so that things are consistent. Right now, all I see are the problems from Perl 5 that have been fixed; I don’t see any of the problems that exist in Perl 6 yet.

  • A lot of the introspection functionality isn’t there yet. Since things are still in flux, there isn’t a lot of concrete documentation on what each class does. Thus, I figured the easiest way to learn what’s there, as opposed to what’s in the spec, was to first figure out the introspection mechanisms and use those to poke around. It turns out that the $foo.HOW().^attributes() method doesn’t exist yet, so looking for the structure of classes isn’t possible yet. However, the $foo.HOW().^methods() method does exist, so I started exploring that. My first try at simply listing the methods on an object (say $_ for 1.^methods()) resulted in some expected stuff, but there were a bunch of “1”s and “2”s in there. It turns out that those are collections of multi methods (which are like overloaded methods in other languages, but the determination of which variant to use is made at runtime, not compile time). This is when I learned that a bunch of Rakudo classes (e.g. the multi method classes) are actually Parrot classes (currently) and thus they don’t act like Perl 6 classes are supposed to, so it’s hard to introspect those.
  • With the goal of starting on Perl6::Critic, I learned that I can get a parse tree via my $parse_tree = Perl6::Grammar.parse($source_code); or my $parse_tree = Perl6::Compiler.compile($parse_tree, :target('parse'));, or even get the abstract syntax tree via my $ast = Perl6::Compiler.compile($parse_tree, :target('past'));.
  • I had heard that Perl 6 supported classes and prototypes, but I had no idea where the prototypes came in. It turns out that Perl 6 classes are actually implemented as prototypes. In fact, classes are “instances” of themselves, specifically the undef instance. So, when you declare a typed variable, but don’t provide an initial value, the undef that the variable gets initialized to is the class itself. Given
        my SomeClass $x;
        my $y = SomeClass;

    $x and $y refer to the identical thing. This is seriously cool stuff.

  • Parrot is far enough along that people are actually discussing cross-language issues such as IPC and standard Parrot libraries.
  • Some people aren’t happy writing code in “assembly language” (PIR) and are thus creating “C” for Parrot (Close, as in “close to C”).
  • Rakudo cannot handle the official Perl 6 grammar,, yet, so I need to work with the Rakudo grammar.
  • I can actually see an approach to tackling Perl::Critic for Perl 6. The first thing I want to do is create a ppidump for Perl 6. Parrot has a means of doing this, but I want something in regular Perl 6, not only for the functionality, but to learn how to walk the parse tree. The next step is to implement a ProhibitMagicNumbers program; no configuration, no options, just take a set of file names and spit some stuff out. Patrick suggested that I could subclass the grammar and use actions on it to find the numbers and look at the surroundings; that would work for a specific policy, but this initial program would be an exploration in how to do the real Perl::Critic and I don’t plan on a grammar subclass per policy. (That would mean that each file would need to be parsed individually for each policy.)