Prototype object model for Parrot

Skip to first unread message

Allison Randal

Feb 5, 2007, 9:40:40 PM2/5/07
to Perl 6 Internals
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
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.


Kevin Te

Feb 6, 2007, 10:57:18 AM2/6/07
to Allison Randal, Perl 6 Internals
I was just starting to port Class::MOP to C PMCs, I would be happy to
help port smop to C PMCs.


Allison Randal

Feb 6, 2007, 11:53:10 AM2/6/07
to Kevin Te, Perl 6 Internals
Kevin Te wrote:
> I was just starting to port Class::MOP to C PMCs, I would be happy to
> help port smop to C PMCs.

Great, let's meet on #parrot later this week.


Reply all
Reply to author
0 new messages