http://www.perlmonks.org?node_id=384937


in reply to Re^2: Solving compositional problems with Perl 6 roles
in thread Solving compositional problems with Perl 6 roles

Ultimately, it appears that the crux of the matter is defining what is a behavior vs. what is a trait.

A thief IS a Character who "implements/HAS" the behavior/interface of methods associated with "thieving". An Elf is a Character who IS a type of Character, who HAS certain additional traits.

It's all going to come down to whether you think of the character as an "elf type-of thief," or a "thief type-of elf." This will determine which is the child class by inheritance, and which is the child by "mix-in".

Just some thoughts,
-v
"Perl. There is no substitute."
  • Comment on Re^3: Solving compositional problems with Perl 6 roles

Replies are listed 'Best First'.
Re^4: Solving compositional problems with Perl 6 roles
by kappa (Chaplain) on Aug 23, 2004 at 12:17 UTC
    Would be nice to NOT know whether $stranger is an "elf type-of thief" or "thief type-of elf" and be able to do this:
    # ".?" means "call if the obj CAN the method" acc. to Apoc12 $stranger.?steal; $stranger.?shoot_arrows;
    and expect DWIMming (doing both things in both cases). That's the whole point of polymorphism, is it not? :)

    Update: upgrade perl5 syntax to perl6 (Apoc12).