The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Perl::MetaClass - A meta-meta-model for Perl Classes

SYNOPSIS

  #         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');

DESCRIPTION

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.

NOTES ON USAGE

Modeling Inheritance

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).

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

METHODS

Perl::MetaClass::new ($name)
clsName($inv: ?$name)
clsSuper($inv: ?$superclass)
clsSubClasses($inv: *@subclasses)
clsIsa ($inv: $class)

This accepts both a Class name and $class instance.

clsProperties($inv: ?%properties)
clsMethods($inv: ?%methods)
clsAssocs($inv: ?%assocs)

AUTHORS

Sam Vilain

Stevan Little <stevan@iinteractive.com>