Instance-based OOP
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
eg
lib
t
xt
.gitignore
.shipit
Changes
MANIFEST.SKIP
Makefile.PL
README.pod

README.pod

NAME

Plass - Instance based OOP

INSTALL

  $ git clone git://github.com/ytnobody/Plass.git
  $ cpanm ./Plass

SYNOPSIS

  my $cat = plass 
      meow => sub { print shift->voice."\n" },
      look => sub { print shift->profile->name. " looking ". shift. "\n" },
      voice => 'Meow...',
      profile => { name => "Kiki", age => 4 },
      surface => [ 'Black', 'Talkable' ];
  
  $cat->meow; ### say "Meow..."
  
  $cat->look( "you" ); ### say "Kiki looking you"
  
  my $talkcat = $cat->plass( 
      voice => "I'm hungry...",
      look => sub { print shift->profile->name. " not looking ". shift. "\n" },
  );
  $talkcat->profile->name( "Jiji" );
  
  $talkcat->meow; ### say "I'm hungry..."
  
  $talkcat->look( "you" ); ### say "Jiji not looking you"
  
  my $bird = plass
      fly => sub { print $_[0]->name. ' flew to '. $_[1]. "\n" };
  
  $talkcat = $talkcat->mix( $bird );
  
  $talkcat->fly( 'mountain' ); ### "Jiji flew to mountain.";

DESCRIPTION

An aim of Plass is to present environment of instance-based-OOP.

COMMANDS

Plass imports follow commands.

plass

 my $instance = plass key => $anyval, key2 => $anyval2 ... ;

Cloning universal instance of Plass. And, Specified parameters to a cloned instance.

mix

 my $instance = mix $plass_instance_1, $plass_instance_2, $plass_instance_3 ... ;

Mixing Plass based instances. But, non-recursive slot inheritance.

METHOD

Instance of Plass can call follow method.

plass

 my $child = $parent->plass( key => $anyval, key2 => $anyval2 ... );

Cloning parent instance of Plass. And, Specified parameters ( calls "trait" ) to a child instance.

mix

 my $child = $parent->mix( $plass_instance1, $plass_instance2 ... );

Cloning parent instance of Plass. And, Mixed-parameters of specified instances to a child instance.

feature

 my %trait = $instance->feature;

Returns trait of instance. Following codes are equal among they.

 my $child = $parent->plass;

 my %trait = $parent->feature;
 my $child = plass %trait;

PHILOSOPHY

SIMPLIFICATION OF CODING

Plass aims destroy partition among class and object.

Specifically, class-name contained in Plass-object is nonsense.

Because Plass-object's class-name is "Plass".

To generate an instance in instance-based-OOP means make clone from an universal instance.

ABLE TO EXTEND EASY

In Plass, inherits is superseded by trait.

Trait is expressed by Hash that contains some-values and/or coderef.

USABILITY OVER SPEED

In developing Plass, please priority over usability than speed.

TODO

- performance benchmark.

- more friendly trait.

AUTHOR

satoshi azuma <ytnobody@gmail.com>

SEE ALSO

LICENSE

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