On Mon, Jun 25, 2001 at 11:36:34PM +0200, Trond Michelsen wrote:
> The downside is of course that I need to make a small stub for every
> single function I want to delegate.

Well, that's relatively simple to automate...

        %Delegations = ( foo    => '_This',
                         bar    => '_This',
                         yar    => '_That',
                       );

        while(my($meth, $key) = %Delegations) {
            *{$meth} = sub {
                my($self) = shift;
                $self->{$key}->$meth(@_);
            };
        }

So $obj->foo(@args) becomes $obj->{_This}->foo(@args).  Ahh, the magic
of closures.

Wasn't Damian working on something like this?  I looked at his
delegation stuff in perl5+i, but it didn't seem to have anything to do
with this sort of delegation.
                

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
<purl> Hey Schwern! honk, honk, honk, honk, honk, honk, honk, honk,
honk, honk, honk, honk, honk, honk, honk, honk, honk, honk, honk,
honk, honk, honk, honk, honk, honk, honk, honk, honk, honk, honk,
honk, honk, honk, honk, honk, honk, honk, honk, honk, honk, honk,
honk, honk, honk, honk, honk, honk, honk, honk, honk, honk!  

Reply via email to