Laying the role meta-foundations

JonathanWorthington on 2009-11-25T01:03:13

I got back from Latvia yesterday. The first Baltic Perl Workshop was very small, but also very enjoyable. I also very much enjoyed meeting up with masak++, who shares my love of good food - curry included! Riga turned out to be a great place for having a good nom, both in terms of local stuff and nice hot curry. And of course, amongst the workshop and some sightseeing, some hacking got done too.

Today was Rakudo Day, and it was time to get back to meta-model matters. I actually spent a while during my time in Riga reading a good bit of Moose and Class::MOP - I'd seen bits of them before, but this time gave the parts relating to roles a much closer look and got myself a refresher on some other bits. I also spent the plane ride home (pretty much the entire flight!) reading an interesting paper on composing meta-objects from traits, which turned out to be a much easier read than I had expected, but left me wanting to read many of its references too.

The first thing I worked on today was getting more details into metamodel.pod, which is the currently under heavy construction specification for Rakudo's meta-model. It will in the future become a proposal for inclusion in the Perl 6 specification too, at which point it'll be time to co-ordinate with other implementations to get something that we can all agree on. Anyway, if you have an interest in meta-programming, you may be interested to give it a read and leave comments, or catch me on #perl6. For those just wanting to see some code rather than read a spec, skip straight down to the example of how writing a module to support something AOP-ish could look. It'll no doubt evolve somewhat, and we won't be able to run it for a little bit yet, but I think it's a nice example of how easy it should be to implement such things in Perl 6.

After that, I dug into starting to get some implementation work done, with a focus on working towards having role composition working as spec'd in the metamodel document. So far I've got a lot of the foundations laid, and I'm now starting to build up on them. So far, it's mostly just plumbing, but composing a role into a class and the class then gaining the role's methods does now work, and a bunch of what we need for required methods and conflict resolution is stubbed in, though untested. I also was able to write a chunk of this in NQP rather than PIR, something I'd like to see us increasingly do in the stage 1 compiler, where it makes sense to do so (the stage 1 compiler containing the things we need in order to compile the setting; the smaller we can keep this part, the better it'll be for us overall...for now the goal is mostly getting the ng branch landed rather than small-stage-1-nirvana though :-)). Anyway, I think I can probably progress pretty fast from here and get our role stuff up and running in the next couple of days.

Thanks to Vienna.pm for sponsoring Rakudo Day.


Metamodel of Joose 3.0

SamuraiJack on 2009-11-25T09:07:06

Hi,

I thought you might be interested to look at the meta-model of the Joose 3.0. Joose is a very close port of Moose to JavaScript. And its sources are much clearer and easier to understand )

It starts with the abstract property:
http://github.com/Joose/Joose/blob/mutability/lib/Joose/Managed/Property.js

And abstract property set (isa property):
http://github.com/Joose/Joose/blob/mutability/lib/Joose/Managed/PropertySet.js

Then defines some kind of "property set algebra", with couple of operations defined: flattening and composition.
Flattening is what happens between roles, when they are listed in the class (produces a new property set), and composition is what happens between class and role.

The whole project can be found here:
http://github.com/Joose/Joose/tree/mutability

And documentation is "borrowed" from Moose :)
http://joose.github.com/Joose/doc/html/Joose/Manual.html

There is an implementation limitation though - Joose supports only one superclass (to fit well into prototype nature of JavaScript)

Regards, Nickolay

A very welcomed addition

lilstevey on 2009-11-25T21:53:21

Hi, I've enjoyed reading your blogs, and found this one particulary interesting - I really enjoyed reading the rakudo metamodel spec. I can't promise any helpfull feedback but, hopefully, given time ( fingers crossed ), I hope to have a play in this area.