On Tue, 7 Jul 2009, Ovid wrote:
role Bomb {
method fuse () { say '3 .. 2 .. 1 ..' }
method explode () { say 'Rock falls. Everybody dies!' }
}
role Spouse {
method fuse () { sleep rand(20); say "Now!" }
method explode () { say 'You worthless piece of junk! Why I should ...' }
}
class PracticalJoke does Bomb does Spouse {
}
class PracticalJoke {
has Bomb $bomb handles <fuse>;
has Spouse $spouse handles <explode>;
}
Note that I have no idea where (if anywhere) the type goes in this.
Hopefully someone will correct me here. Note that this does not use the roles
as roles; it uses them punned as classes. But it does what you asked :).
:)
---------------------------------------------------------------------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayl...@wayland.id.au | I am |
---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----