Hello All,

Since autrijus is now busy porting the P5 metamodel prototype into Haskell for use in Pugs, I have decided to begin work on documenting the Perl6::MetaModel prototype modules more thoroughly. The first step I see in this is to define a Meta Object Protocol (aka - the stuff you can do with/to $obj.meta).

I have reviewed the relevant sections in Syn/Apoc 12 and am now writing a small add-on (I am calling it Syn 12.5 for now) which I hope will can augment the relevant sections from Syn/Apoc 12. As soon as the document is complete enough, I will post it here, or you can see it here (http://svn.openfoundry.org/pugs/perl5/Perl6-MetaModel/docs/) as it is being developed. I welcome all comments, questions and suggestions .... oh, and help too :).

This now brings me to the second item mentioned in the subject line.

So..., as far as I see it, the following statements are true about the metamodel.

1) MetaClass is a subclass of Object
2) MetaClass is an instance of MetaClass

So the following code should be true (given a random instance $obj).

  $obj.meta.isa(MetaClass);
  $obj.meta.isa(Object);

Because after all, the object returned from $obj.meta should be a MetaClass instance right?

However, Syn/Apoc 12 shows that the following is true if $foo is an instance of the Foo class.

  $foo.meta.isa(Foo)

And that $foo.isa(Foo) actually is just an alias for $foo.meta.isa(Foo).

So I am sure you can see my problem here.

The p5 prototype currently handles it as such:

  $foo->isa(Foo) # returns true if $foo is an instance of Foo
$foo->meta->isa(MetaClass) # returns true since $foo->meta returns a MetaClass instance
  $foo->meta->is_a(Foo) # returns true, note the added '_'

Personally I am not a fan of the 'is_a' name, I just did it one day, and it sort of stuck. But I do think we need to find a way to differentiate between the two questions:

- What class are you an instance of?
- What class are you describing?

The first question can be asked of anything which inherits from Object. The second question is really only relevant to MetaClass instances.

Thoughts, Comments, Suggestions?

Thanks,

- Stevan



Reply via email to