On Mon, Sep 04, 2000 at 09:53:39PM -0000, Perl6 RFC Librarian wrote:
> Objects : Core support for method delegation

I like it!  One gripe (of course)...


> The proposed delegation mechanism would work via a pragma:
> 
>       use delegation
>               attr1 => [qw( method1 method2 method3 )],
>               attr2 => [qw( method4 method5 )],
>               attr3 => [],
>               attr4 => [],

I will often use a more complicated data structure for my objects,
often organizing all sub-objects into a hash of hashes...

    $obj->{locks}{MacOSX} = $macosx_obj;
    $obj->{locks}{Mac}    = $mac_obj;
    $obj->{locks}{BSD}    = $bsd_obj;

which is nice when you stuff alot of things into an object.  If I
wanted to deligate to those objects in $obj->{locks}, how would I
under your proposal?

In a similar vein, I can see a use for wanting to deligate a set of
methods to an entire list of objects.  Consider...

    $obj->{locks} = [$macosx_obj, $mac_obj, $bsd_obj];

it would be nice to be able to state that "method1" should deligate to
each object in the $obj->{locks} list until it is found.


Also, what happens when a deligated attribute does not contain an
object when Perl checks?  Should it produce a warning?  I'd say no.  I
can easily see cases where you'd like to be able to deligate to
objects which may or may not be instanciated at run-time.  If a
warning was issued, it would be difficult to circumvent.  You'd have
to place a dummy object in that slot.


PS You mentioned Class::Classless.  Does any other language or system
implement deligations?


-- 

Michael G Schwern      http://www.pobox.com/~schwern/      [EMAIL PROTECTED]
Just Another Stupid Consultant                      Perl6 Kwalitee Ashuranse
Long, long time ago, in a far away galaxy, cells were formed. Cells are
building blocks of different chemicals.
             --Alex Chiu, Immortality Guy

Reply via email to