[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: finite state machine in lua
- From: Jorge <xxopxe@...>
- Date: Mon, 29 Apr 2019 00:40:27 -0300
On 28/4/19 23:39, Srinivas Murthy wrote:
I need to use this for a real-time event sampling use-case.
https://gitlab.fing.edu.uy/jvisca/ahsm does seem interesting but the
cautionary note that its "very alpha quality and not tested ..." is
I already considered removing that disclaimer. I should remove it. I
will. Any moment now :\
Is there any other libs that you could recommend?
When I needed a plain state machine I just rolled my own following one
of two patterns, the one from
http://lua-users.org/wiki/FiniteStateMachine and the "functional" one
(you can see an example of such machine parsing a protocol here:
In these cases writing the machine felt pretty natural in the code
itself, and I did not feel the need to use an abstracted library.
When the SM is more complex a library makes sense. We tried to use rFSM
(https://github.com/kmarkus/rFSM), but run out of memory, and there
seemed to be too much complexity in there. I just wrote a implementation
based on its API. This is not the first time this happens to me, find a
library with an API I want to use, find the implementation too complex
or with lots of stuff I don't need, and then write my own library from
scratch inspired by that. I suspect that means that the API is actually
the hardest part of the library design.