On Sat, 2003-08-09 at 06:55, Dave Rolsky wrote:
> So what I think we really want is this:
>
>   my $Wrapper = DT::Wrapper->wrapper( [$class1, $class2, $class3] );
>

On Fri, 9 Aug 2003, Rick Measham wrote:
> > Maybe my approach has some holes, but have a look at the attached and
> > see what you think ...
> 

On Sun, 2003-08-10 at 00:40, Dave Rolsky wrote:
> The big hole is that you set @ISA when you create the decorator, but what
> if someone creates two _different_ decorators?  In that case you've just
> broken the first one you made.

Oh dang! Of course! Should have thought of that. Pity we can't get @ISA
as a part of the object

> Also, we want to be able to use SUPER::foo inside the decorating classes.
> For example, Josh's DT::Cache will obviously need to call it's parent's
> new() method.

Hmmm .. ok .. so If DT::Cache isn't the last module in the array then it
won't work? Seems to me that decorators should be able to be anywhere in
the list. What if some other decorator comes along that has to be last
in the chain? Then you can only use one or the other.

> This means that we can't just use multiple inheritance, but instead we
> need to create an actual chain of inheritance.

Another suggestion: Look at Sex as a possibly adaptable option. Sex is a
module written tounge-in-cheek by Michael Schwern but if you take all
the grunting out, it may be useful:
http://search.cpan.org/author/MSCHWERN/Sex-0.69/Sex.pm

Yet another: Each decorator has a 'decorate' method that takes a list of
modules to decorate itself with. Basically it grabs the one off the end
and 'uses' what it grabbed. Then it calls decorator in the grabbed
module, passing it whatever is left of the list.

Both of these may have the same problems as my original solution. I'm
thinking out loud and I'm not an OO guru :)

Cheers!
Rick

Reply via email to