Plass - Instance based OOP
$ git clone git://github.com/ytnobody/Plass.git
$ cpanm ./Plass
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.";
An aim of Plass is to present environment of instance-based-OOP.
Plass imports follow commands.
my $instance = plass key => $anyval, key2 => $anyval2 ... ;
Cloning universal instance of Plass. And, Specified parameters to a cloned instance.
my $instance = mix $plass_instance_1, $plass_instance_2, $plass_instance_3 ... ;
Mixing Plass based instances. But, non-recursive slot inheritance.
Instance of Plass can call follow method.
my $child = $parent->plass( key => $anyval, key2 => $anyval2 ... );
Cloning parent instance of Plass. And, Specified parameters ( calls "trait" ) to a child instance.
my $child = $parent->mix( $plass_instance1, $plass_instance2 ... );
Cloning parent instance of Plass. And, Mixed-parameters of specified instances to a child instance.
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;
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.
In Plass, inherits is superseded by trait.
Trait is expressed by Hash that contains some-values and/or coderef.
In developing Plass, please priority over usability than speed.
- performance benchmark.
- more friendly trait.
satoshi azuma <[email protected]>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.