in reply to Re: Free-Form Delegated Behavior
in thread Free-Form Delegated Behavior
That sounds a lot like Roles in Perl 6 or Moose. So today I could just add a role to a class using with within the class (or after the fact if it's not been sealed), or even do it on a per-object basis. The latter doesn't have supplied syntactic sugar in Moose but is a primitive in Perl 6.
Your implementation has an interesting feature in specifying which methods are injected into the host class, rather than just taking all of them. That means within that method, a dispatched call will see the host object, but a regular sub call will be compiled in the scope of the package it was actually declared in. It can call non-virtual helpers that don't become overridable in the host class.
I think as a means of changing/extending the functionality of a class, this is the same as deriving a new class. Roles and plug-ins just allow such units of extensibility to be packaged and reused easier.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Free-Form Delegated Behavior
by pemungkah (Priest) on Jul 02, 2011 at 19:18 UTC |