Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Beware of object composition!

by merlyn (Sage)
on Feb 05, 2010 at 18:23 UTC ( #821627=note: print w/replies, xml ) Need Help??

in reply to Beware of object composition!

use Moose; use Your::Delegated::Class; has ydc => is => 'ro', lazy_build => 1, handles => qr/.*/, isa => 'You +r::Delegated::Class'; sub _build_ydc { my $self = shift; return Your::Delegated::Class->new; }
Moose is smart enough to delegate only the things that Your::Delegated::Class knows how to handle, minus the things defined locally. It's like AUTOLOAD delegation, done right. I used this on a recent project when what I wanted was inheritance, but had to use composition and delegation.

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Replies are listed 'Best First'.
Re^2: Beware of object composition!
by Jenda (Abbot) on Feb 05, 2010 at 19:12 UTC

    As if I had a chance of having Moose installed sooner than after a year of writing change requests, chasing people several levels up and around to approve them, rewriting them, rerewriting them, getting them rejected by people that write Pearl and think Moose is the animal, resubmitting, ...

    I really should get me a different job.

    Thanks anyway of course :-)

    Enoch was right!
    Enjoy the last years of Rome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821627]
[1nickt]: marto all good after the hurricane?
erix .o.O ( I reckon yet again some pieces broke off UK are added to NL downstream... )
erix joining the EU after all

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-10-17 10:30 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (225 votes). Check out past polls.