Slash Boxes
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 ]

JonathanWorthington (6049)

  (email not shown publicly)
Tuesday January 22, 2008
07:08 PM

Implementing Perl 6 OO

[ #35462 ]

So last time I wrote, I hoped not to get too many issues that kept me from hacking on Perl 6 and Parrot. As it happens, I did get sick and that wiped me out for about a week. :-( This week I've had a more fun reason not to be doing so much, which is that I've got a friend visiting me. They're the first person I've had to visit since I got my own place out here in Spain, so it's been great fun showing them some places, taking them on a tapas crawl (lots of delicious food and beer) and so on.

Amongst it all, I found time to write a few lines of code for the Perl 6 compiler. I really, really didn't want to go to Ukraine and talk about the Perl 6 object model without people being able to play with it. So...I started implementing it. And now you can have classes with methods and attributes.

class Foo {
    has $a;
    method set {
        $a = "w00t";
    method get {
        say $a;

my $x =;
$x.get(); # prints w00t

No accessor and/or mutator methods yet, but I plan to do those next. Then I will do compile time role composition, provided everyone is happy with me doing so. I already implemented roles and the composition algorithm in Parrot anyway, so it should be relatively easy to get the basics of that into the Perl 6 compiler too.

Beyond that, my personal roadmap (as in, what I plan to hack on if it doesn't get in the way of what others are doing) is:

  • Refactoring to get every non-Junction type inheriting from Any.
  • Parsing type annotations on parameters and variables.
  • Getting those type annotations to be applied to MMD (so we get type-based MMD dispatch as well as the arity based one that already works).
  • Re-implementing junction auto-threading in terms of MMD, as it should be done.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Is this available as part of the perl6 executable? or the Radoku compiler? How can I start playing with this?

    We have accumulated well over 3000 unit tests in Moose and Class::MOP, and I am sure at least 1/2 to 2/3rds of them are relevant enough to Perl 6 that they would be useful here. Especially some of the nasty edge cases we have discovered with Role composition, it would save you from having to find them on your own. Feel free to pop over to #moose on or email me directly.

    - Stevan

    • Neat.

      This should mean I can port my Hilbert's Curve code from Perl and C++ and add it to the "What can I do with Perl 6 today" wiki page.

      @JAPH = qw(Hacker Perl Another Just);
      print reverse @JAPH;
    • It's in the Parrot svn repository, under languages/perl6/. So if you get the latest from there, and then "make perl6", then you will be able to play with this. As I said, it's only very early work at the moment so don't expect to do anything other than the very minimal things I posted. I will keep hacking on it, though. :-)

      The tests sound very interesting. I guess the place for them really is the Perl 6 test repository (in the Pugs SVN), then we can pull them down for testing Radoku but they are available f
  • Very nice. Added to the rakudo blog: []