mop problem 3 - class, extends, and method keyword should be independent from mop

mop provide class, extends, and method keyword to perl. but I think these keyword should be independent from mop because these keyword is useful for non-mop modules.

I opposite only mop use these keywords. I hope these keyword is used for other modules the keywords need.

For example, current hash based module is rewrite in the following way.

Before:

package Point3D;
use Object::Simple -base => 'Point';

has z => 1;

sub clear {
my $self = shift;
...
}

After:

use Object::Simple::Syntax;

class Point3D extends Point {
has x => 1;

method clear {
...
}
} 

I think class, extends, and method keyword is not for only meta-object protocol. I think these keyword should be designed for hash-based object.

Hash based object is current perl major implementation of Object-Oriented program. New syntax should help hash based object, not only mop.


3 Comments

I think the argument against making class, extends, and method work outside mop would be:

Once mop is in core, why would you want to write any object-oriented code without using mop?

There are certainly valid answers to that, such as, I need to support Perl 5.8.x. But if you need to support Perl 5.8.x, then you can't use any new keywords (such as class, extends, and method) introduced in Perl 5.2x.y anyway.

The current prototype (#3) is separating the syntax and the mop itself.

Also, we dropped the inside-out thing, now it is going to be an opaque C pointer.

Leave a comment

About Yuki Kimoto

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