NAME
MOP - A Meta Object Protocol for Perl 5
VERSION
version 0.14
SYNOPSIS
use MOP;
my $m = MOP::Class->new( 'Foo' );
printf 'Introspecting %s package with version %s', $m->name, $m->version;
foreach my $s ( $m->all_slots ) {
printf 'Found slot %s', $s->name;
}
foreach my $m ( $m->all_methods ) {
printf 'Found method %s', $m->name;
}
DESCRIPTION
This module implements a Meta Object Protocol for Perl 5 with minimal overhead and no non-core dependencies (eventually).
A Meta Object Protocol, or MOP, is an API to the various parts of the an object system.
CONCEPTS
There are only a few key concepts in the MOP, which are described below.
MOP::Role
A role is simply a package which may have methods, may have slot defintions, and may consume other roles.
MOP::Class
A class does all the things a role does, with the addition of inheritance and instance construction.
MOP::Slot
A slot is best thought of as representing a single entry in the package scoped %HAS
variable. This is basically just building upon the conceptual model laid out by UNIVERSAL::Object.
MOP::Method
A method is simply a wrapper around a reference to a CODE slot inside a given package.
SEE ALSO
UNIVERSAL::Object
This module uses the UNIVERSAL::Object module as the chosen instance construction protocol, but also in its introspection assumes that a class uses the conventions of UNIVERSAL::Object specifically with regards to slot storage.
Class::MOP
Almost 10 years ago I wrote Class::MOP, whose purpose was also to bring a MOP to Perl 5. While these modules may have had the same goal, they have different requirements and priorities and so shouldn't be compared directly.
AUTHOR
Stevan Little <stevan@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017, 2018 by Stevan Little.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.