Finite state machine in D

Druzhinin Alexandr news at digitalmars.com
Thu Sep 27 05:39:45 PDT 2012


27.09.2012 18:15, Philippe Sigaud пишет:
 >
 > I'm not sure you need code generation. Using D functions literals or
 > closures already gives you a good part of a FSM:
 >
 > States are functions, that accept a current 'payload' and return a
 > tuple consisting of another function and the new payload.
 > The FSM driver just call the current state on the current payload,
 > stores the new stat/payload pair and loop until it reaches a terminal
 > state.
 >
 > I can search at home to see what I have (if I kept anything), if
 > you're interested. It's a FSM in 10-20 lines of code, IIRC.
 >
yes, I'm interested. Thanks in advance.

What about code generation - I just want to learn how to do it, so


More information about the Digitalmars-d-learn mailing list