|Don't ask to ask, just ask|
Re^4: a State machine with Roles - possible? (class or instance)by mascip (Pilgrim)
|on May 30, 2013 at 14:27 UTC||Need Help??|
Thanks for the discussion LanX :-) I think that you're looking for something too complicated, and that Roles just do the trick. (i might well be wrong). Here is the Perl code for getting the same behavior as the Ruby code from the slides (it could all be shorter and put in the same file, with MooseX::Declare - but some people might not have it installed):
Which does what is expected (output written as comments in test.pl).
But it has several problems:
If there were simple solutions to these two problems, then i think we could implement complex State machines with multidimensional states.
There is here someone who asked pretty much the same question as me, with a pretty good example of multidimensional State machine: a warrior who can be turned into a Zombie, poisoned, made stronger, turned into a Chipmunk, or all of these at the same time. The answer to that person's question was an alternative solution with aspects. I would still prefer the solution with Roles, which are more flexible, and in my opinion clearer.
Was that clear? Helpful? Did i miss your point LanX?