NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Applying several runtime Traits (Score:1)
Applying several traits to an instance should not do anything different than applying one. So for instance this (in pseudo Perl 6):
Would become this (in Perl 5 Traits):
Basically apply should return the reblessed instance, and you just keep chaining them.
Now, this may not be the most efficient approach, but I am not really sure that would matter since runtime application of multiple traits will probably be a rare occuranc
Re: (Score:1)
I think that’s the key to a bearable syntax: have a
Class::Traits::compose, returning an anonymous trait which is a composition of the given traits, on which you then simply invokeapply:Class::Traits->compose( "Tricks", "Treats" )->apply( $fido );Reply to This
Parent