just a thought

nkuipers nkuipers at uvic.ca
Thu Feb 20 12:46:16 CST 2003


Yesterday I inadvertently illustrated use of "delegation" in Perl, in a 
roundabout way to establish inheritance in my BIO:: namespace.  Peter, in 
addition to showing me the easy way to Perl inheritance, mentioned that there 
is a raging controversy among OO purists about when (if ever?) delegation 
should be used.  I am thinking that this is a tremendously useful way to 
implement multiple inheritance.  In the child class constructor, you could 
have a key for each parent name, where the value is the call to that parent's 
constructor.  It would then be very easy to call any method from any parent, 
right from the child object:

$object->{super1}->fooperdooper();
$object->{super2}->bazball();

You would also allow easy, hardcoded access to identically named methods in 
different parents:

$object->{super1}->kindasorta();
$object->{super2}->kindasorta();

Am I more or less correct in my "realizations" about delegation?  If so, I 
find it to be really quite exciting.

Cheers all,

Nathanael




More information about the Victoria-pm mailing list