Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Sunday July 02, 2006
02:44 PM

Dancing with Class::MOP

[ #30142 ]

My first impression of Class::MOP was WTF?. The "Meta Object Protocol" sounds awfully abstract. I thought it was Perl6 weirdness invading Perl 5.

Last night I began to understand what it's good for. To implement a plugin system, CGI::Application uses introspection to examine the ancestry of classes that have been inherited from. This allows callbacks in each ancestoral class to be executed.

We had been using "Class::ISA" to do this, which provides some related procedures.

Class::MOP formalizes, and in my opinion cleans up, access to this internal, or "meta" class information. It does so by adding a "meta" class method. Through it, this kind of meta-class information can be queried on demand. In my case, the syntax looked like this:

my @ancestors = Project->meta->class_precedence_list;

Not so hard.

It seems in Perl6 "ISA" is gone, and the kind syntax provided through Class::MOP replaces it. This means that be using Class::MOP now, we can be learning about Perl6, and making our code even easier to port when the time comes.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.