Emperor [SPUG: E-spug takers?]

Colin Meyer cmeyer at zipcon.net
Fri Dec 17 18:19:54 CST 1999


On Fri, Dec 17, 1999 at 01:37:25PM -0800, Stuart Poulin wrote:
> print "I'll be there" if $day !~ /^Tue/i;
> 
> There's got to be some clever way to say $Emperor = new clothes; but I can't
> think of it.
>

I think that it is more of a "has-a" rather than an "is-a" relationship:

$emp = new Sovereign;

$naught = new Clothes;
$naught->composed_of(undef);
$naught->looks_like('invisible');

$emp->dress_in($naught);

print $emp->dressed_in->looks_like();

Where looks_like() and composed_of() are accessor methods for attributes of
object class Clothes and dress_in()/dressed_in() are set/get methods for an
attribute of class Sovereign.

It is probably confusing to use two different object attribute accessing
interfraces in the same segment of code, but you can do that in Perl.  In fact
you have to use arbitrarily different object interfaces when combining the
usage of several random modules from CPAN in one program...

-C.

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list