mop problem 4 - mop is misleading name

I want to write all mop problems I am thinking before mop is added to Perl core.

mop is abbreviation of Meta Object Protocol. I think this name is misleading name. This name associate "Meta information of Object ".

But truth is that any information is Class Information, not Object information.

For example,

1. Attribute name
2. Parent class
3. Role

This is belong to Class, not Object.

    ref $object
        -> Class
            -> Attribute name
            -> Parent class
            -> Role information

The following concept is not good.

    meta($object)
        -> Attribute name
        -> Parent class
        -> Role information

If all object have meta information, this is heavy cost. Information should be shared in Class, and Object should be container of only data.

Reply of Comments

I'm wrong. I'm completely had mistake of the mean of meta. I think mop is not bad name.

But I think object is cost if there are 1000 Classes and the class have 20 attribute and methods. the total of all attribute objects of all classes and all methods of all classes is 20000.

I think bless x 20000 is cost. If API is provided, internal data is good to be created as hash reference and array reference?

4 Comments

I have often thought about making a truely first-class "CLASS" type in Perl, references to which are returned by the ref() operator on "normal" objects.

foreach my $mth ( ref($self)->methods ) {
...
}

e.g..

Or failing that, we steal some new syntax out of Perl6 - the meta ear maybe?

foreach my $mth ( $self^->methods ) {
...
}

"But truth is that any information is Class Information, not Object information."

I don't think the "o" in "mop" is trying to suggest that it only keeps meta information about objects (and not about classes, roles, methods, attributes, etc). Instead it means that the meta information is represented as objects (rather than, say, unblessed hashrefs and arrayrefs).

"If all object have meta information, this is heavy cost."

It's cheap if you only gather the meta information when requested. For example, say you can get a list of an objects methods like this:

my $object  = $class->new();
my @methods = $object->meta->methods;

That doesn't imply that mop needs to generate the list of methods for $object during the $class->new() constructor, and carry around that list of methods until the object is destroyed.

Rather, when you call $object->meta->methods it will then realize you want a list of methods, and only then gather the list of methods from $class and any superclasses, roles, etc.

Yes, "mop" is kind of an obscure name, it might change before being added to the core.

However, your reasoning is incorrect. With a meta-circular object model, everything is an object, a class (as represented in the mop) is simply an instance of the class "Class" (and yes, the class "Class" is itself an instance of the class "Class", which is where the bootstrap comes in).

Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.