Perl::MetaClass - A meta-meta-model for Perl Classes
# Package # | # +-----+----+ # | | # Module Role # | # Class my $package = Perl::MetaClass::new('Package'); my $role = Perl::MetaClass::new('Role'); my $module = Perl::MetaClass::new('Module'); $role.clsSuper($package); $module.clsSuper($package); my $class = Perl::MetaClass::new('Class'); $class.clsSuper($role); $class.clsIsa('Package');
Perl::MetaClass is the meta-model of the Perl6 object system. The code in this module itself is the meta-meta-model of the Perl6 object system.
See the Perl::MetaModel module for more details.
Inheritance relationships are best defined using .clsSuper rather that .clsSubClasses. Currently .clsSuper will deal with all subclass related issues automagically, while .clsSubClasses will not allow a subclass to be assigned unless already has it's superclass assigned (which would have already taken care of the subclass, making the entire action redundant anyway).
.clsSuper
.clsSubClasses
So this means that this is the proper way to set up an inheritance relationship:
my $package = Perl::MetaClass::new('Package'); my $role = Perl::MetaClass::new('Role'); $role.clsSuper($package);
And this code would fail:
my $package = Perl::MetaClass::new('Package'); my $role = Perl::MetaClass::new('Role'); $package.clsSubClasses($role); # << this will die
And this would just be redundant:
my $package = Perl::MetaClass::new('Package'); my $role = Perl::MetaClass::new('Role'); $role.clsSuper($package); $package.clsSubClasses($role); # << this is redundant, it is already done automagically
This accepts both a Class name and $class instance.
$class
Sam Vilain
Stevan Little <stevan@iinteractive.com>
To install Perl6::Pugs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl6::Pugs
CPAN shell
perl -MCPAN -e shell install Perl6::Pugs
For more information on module installation, please visit the detailed CPAN module installation guide.