[Pdx-pm] Poll: traits

Eric Wilhelm scratchcomputing at gmail.com
Sat Nov 19 12:12:27 PST 2005


# from Ovid
# on Saturday 19 November 2005 11:17 am:

>  package FamilyMember;
>  use Class::Trait
>    TSpouse => { exclude => ['fuse'] },
>    TBomb   => { exclude => ['explode'] };
>
>And now FamilyMember->can('explode') (from TSpouse) and
>FamilyMember->can('fuse') (from TBomb).

So, in this case, it's the same as

  use TSpouse qw(explode);
  use TBomb qw(fuse);

Right?

Of course, that assumes that these methods are at least in @EXPORT_OK, 
and it looks like you've done something handier than that with 
Class::Trait (besides, most people wouldn't think to export method 
names, would they?)

Now I can change my answer to "of course I use them", but iirc, I've 
only ever done it with the (not so meticulous) do("traitfile") :-)

So, I can see some benefits here, particularly in the collision 
detection, exclusion or inclusion, etc.  I just wish you had presented 
it that way instead of with a link to a 143 page paper, where most of 
the discussion centers around the fact that he's dealing with a 
language where pragmatic code reuse is hindered by an overly formalized 
OO system.

--Eric
-- 
hobgoblin n 1: (folklore) a small grotesque supernatural creature that
          makes trouble for human beings
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------


More information about the Pdx-pm-list mailing list