I was just starting to port Class::MOP to C PMCs, I would be happy to help port smop to C PMCs.

Kevin

   Allison Randal wrote:
I spent yesterday pair programming with Sam Vilain on a prototype object model written in PIR. We actually wrote two prototypes. The first one had 2 levels of meta objects and the system was getting pretty convoluted, so we scrapped it and started over.

I just checked in the second prototype to compilers/smop (Simple Meta Object Protocol). The prototype has two classes, Class.pir, and Attribute.pir. The instance of Class.pir is a class object, and the instance of a class object is an object.

    .local pmc class, init_args, myobj
    init_args = new Hash
    init_args['name'] = 'MyClass'
    class = new 'Class', init_args
    class.add_attribute('myattribute')
    myobj = class.'new'( 'myattribute' => "Foo" )

The prototype code bootstraps off the existing object model, so for now you create a class object with "new 'Class'". Ultimately this will be the newclass opcode instead:

#   class = newclass 'MyClass'

An Attribute is a simple datatype that stores the attribute name, its type (if any), and a link back to the class that contains the attribute. (It's the class's pattern for the attribute, not the storage for the attribute value.)

This is a simple object model, but it can be used to implement as many meta-levels as a particular HLL needs. Each level of class object is just an instance of the next higher level of meta class object.

To move past bootstrapping on the current object model, the next step is to implement this prototype at the C PMC level, and incorporate much of the functionality of src/objects.c.

Allison

Reply via email to