59 ms·
Can someone give a simple explanation as to what "parameterized roles" are? The article assumes knowledge of some Perl libraries; it does sound interesting but
by sho 17y ago
Can someone give a simple explanation as to what "parameterized roles" are? The article assumes knowledge of some Perl libraries; it does sound interesting but I have no idea what the author is talking about.
- draegtun 17y agoDid u follow the Perl6 parameter role link in the article? This provides a nice example which may help.... role Greet[Str $greeting] { method greet() { say $greeting } } class EnglishMan does Greet["Hello"] { } class Slovak does Greet["Ahoj"] { } class Lolcat does Greet["OH HAI"] { } EnglishMan.new.greet(); # Hello Slovak.new.greet(); # Ahoj Lolcat.new.greet(); # OH HAI http://rakudo.org/2009/01/parametric-roles.html http://rakudo.org/2009/01/parametric-roles.html
- sho 17y agoOops, didn't see your reply for a while. I'll check out the explanation - very interesting to me since I've been grappling with implementing flexible roles programmatically for a while. Thanks for the link!