So I want to write a module that lets you do something like this:

 my $class = hierarchy( 'Foo::Top', 'Foo::Middle', 'Foo::Last' );

 my $foo = $class->new;

 my $other_class = hierarchy( 'Foo::Middle', 'Foo::Top', 'Foo::Last' );


So the idea is that you give it a list of classes, and it dynamically
creates a new class that has as its ancestors the classes you specified.
There's a lot of trickery that would need to be involved here, as you
can't simply alter @ISA for the specified classes, and I'm not entirely
sure how I'll implement it, but that's a separate problem.

First, I need a name.  I'm pretty sure this belongs under the Class::
namespace, so here's a few I came up with:

  Class::DynamicWrapper

  Class::DynamicISA

  Class::DynamicInheritance

  Class::Chain

I don't particularly love any of these.

Also, to forestall some objections, this is not the same as decoration.
In particular, I want the class at the top of the hierarchy to be able to
call $self->foo and have that handled by the foo method in the bottom of
the hierarchy if necessary.  With decoration, this isn't possible.  I also
want can() to just work properly.

This is designed for cases where you have a base module, like DateTime,
and people want to offer extensions best implemented as subclasses, like
caching or different parameter validation, or whatever.  Since there may
be multiple orthogonal subclasses, I want end users to be able to combine
them as they see fit.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to