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
Kevin
Great, let's meet on #parrot later this week.
Allison