Stevan Little > mop-0.03-TRIAL > mop

Download:
mop-0.03-TRIAL.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

mop - A new object system for Perl 5

VERSION ^

version 0.03

SYNOPSIS ^

    use mop;

    class Point {
        has $!x is ro = 0;
        has $!y is ro = 0;

        method clear {
            ($!x, $!y) = (0, 0);
        }
    }

    class Point3D extends Point {
        has $!z is ro = 0;

        method clear {
            $self->next::method;
            $!z = 0;
        }
    }

    my $p = Point3D->new(x => 4, y => 2, z => 8);

    # "x: 4, y: 2, z: 8"
    printf("x: %d, y: %d, z: %d\n", $p->x, $p->y, $p->z);

STATEMENT OF INTENT ^

This is a prototype for a new object system for Perl 5, it is our intent to try and get this into the core of Perl 5. This is being released to CPAN so that the community at large can test it out and provide feedback.

It can not be overstated that this is an early prototype, which means that nothing here is final and everything could change. That said we are quite happy with the current state and after several months of working with it, feel that it is solid enough to go out to CPAN and withstand the cold harsh light of day.

FAQs ^

How can I help?

Thanks for asking, there are several things that you can do to help!

Contributing/reviewing documentation

Documentation is not one of our strong suits, any help on this would be very much appreciated. Especially documetation written from the perspective of users without prior knowledge of MOPs and/or Moose.

Please send any and all patches as pull requests to our repository on github.

Porting a module

Early on in the development of this we started porting existing Perl OO modules to use the mop. This proved to be a really excellent way of uncovering edge cases and issues. We currently have 9 ported modules in our Travis smoke test and are always looking for more.

If you do port something, please let us know via the github issue tracker so that we can add it to our smoke tests.

Writing a module

Porting existing modules to the mop is interesting, but we are also interested in having people try it out from scratch. We currently only have 1 original module in our Travis smoke test and are always looking for more.

If you do write something using the mop, please let us know via the github issue tracker so that we can add it to our smoke tests.

Speak to us

We are always open for a reasonable, civil discourse on what it is we are trying to do here. If you have ideas or issues with anything you see here please submit your thoughts via the github issue tracker so that it can be discussed.

Trolls are welcome, but beware, we may try to hug you!

Hack with us

There are still many things to be done, if you want to help we would love to have it. Please stop by and see us in the #p5-mop channel on irc.perl.org to discuss. Specifically we are looking for XS hacker and perlguts specialists.

Spread the word

The Perl community is a notorious echo chamber, itself filled with smaller, more specific, echo chambers (OMG - it's echo chambers all the way down!). If you are reading this, clearly you are inside, or in the vicinity of, this particular echo chamber and so please if you like what we are doing, spread the word. Write a blog post, send a tweet into the ether, give a talk at your local tech meetup, anything that helps get the word out is a good thing.

Side note: We have been using the #p5mop hashtag on twitter and in blog posts, please continue that trend so things can be easily aggregated.

Why aren't you supporting @features from $my_favorite_oo_module?

It is our intention to keep the core mop as simple as possible and to allow for users to easily extend it to support their favorite features. If you have any questions about writing said extensions or feel that we are really should support a given feature in core, please submit an issue to the github issue tracker so that it can be discussed.

Why are you messing up Perl, I like it how it is!?!?!

We are absolutely 100% NOT going to remove any of the existing OO support in Perl FULL STOP.

We are developing this feature fully in keeping with the long standing commitment to backward compatibility that Perl is famous for. We are also committed to making this new object system work as seamlessly as possible with all of the existing Perl OO features.

Why is it so slow?

It is a prototype, first we had to get it right, next we will make it fast. We have a number of planned optimizations in the works and are confident that ultimately speed will not be an issue.

Can I use this in production?

Probably not a good idea, but hey, it's your codebase. If you are crazy enough to do this, please let us know how it goes!

What version of Perl do you expect this to ship with?

Well, we would like it to be included as experimental in 5.22, but that might be a little tight, time will tell. In the meantime we will try and keep supporting a CPAN version as long as it is possible.

PUBLIC UTILITY FUNCTIONS ^

The following is a list of public utility functions to be used along with the MOP.

meta($obj_or_class_name)

Given an object instance or a class name, this will return the meta-object associated with it. If there is no meta-object associated with it, meaning it is not a MOP class or role, then undef will be returned.

id($obj)

Given an instance this will return the unique ID given to that instance. This ID is the key used throughout many of the MOP internals to identify this instance.

is_mop_object($obj)

This predicate will return true of the instance if a MOP object, and false otherwise.

dump_object($obj)

This is a simple utility function that takes an instance and returns a HASH ref dump of the data contained within the instance. This is necessary because MOP instances are opaque and cannot be dumped using the existing tools (ex: Data::Dumper, etc.).

NOTE: This is a temporary situation, once this system is accepted into core, we expect that the tools will add support accordingly.

OTHER FUNCTIONS ^

The following are functions that are unlikely to be useful to any but the most daring of users. Use with great caution!

apply_metaclass($obj, $metaclass_name_or_instance)

Given an instance and a class name, this will perform all the necessary metaclass compatibility checks and then rebless the instance accordingly.

apply_metarole($obj, $metarole_name_or_instance)

Given an instance and a role name, this creates a new metaclass which extends $obj's metaclass and does the given role, and then calls apply_metaclass on $obj and the new class.

rebless($obj, $class_name)

Given an instance and a class name, this will handle reblessing the instance into the class and assure that all the correct initializations are done.

remove_meta($class_name)

This will remove the metaclass associated with a given $class_name, after this meta will return undef.

initialize()

This will bootstrap the MOP, you really should never call this we will do it for you.

BUGS ^

Since this module is still under development we would prefer to not use the RT bug queue and instead use the built in issue tracker on Github.

Git Repository

Issue Tracker

AUTHOR ^

Stevan Little <stevan.little@iinteractive.com>

Jesse Luehrs <doy@tozt.net>

Florian Ragwitz <rafl@debian.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013-2014 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: