3 ms·
Haha, thanks for your reply, I will improve my documentation to make the descriptions more accurate, and you may raise some issues to help this library better.
by goless 1y ago
Haha, thanks for your reply, I will improve my documentation to make the descriptions more accurate, and you may raise some issues to help this library better.
As for why semantic composition is used, the following example may be instructive:
yes_or_no(exit,a) This means confirm once before exiting
yes_or_no(yes_or_no(exit,a),a) Confirm twice before exiting
yes_or_no(yes_or_no(yes_or_no(exit,a),a),a) Confirm three times before exiting
This is very similar to the composition you describe.
This is the actual code:
https://github.com/sdzx-1/polystate-examples/blob/fecaffb5b7f5eba09c9428c18f1cd97e7ee09e71/src/exe-counter.zig#L61 https://github.com/sdzx-1/polystate-examples/blob/fecaffb5b7...
If there is no name for this way of using state machines, then semantic composition seems appropriate.
Exceptionally, combining two states in a polystate may actually be combining two small state machines, and I think nested selects are sufficient to illustrate this.
https://github.com/sdzx-1/ray-game/blob/9646bc3c0f1c11314aafbc7ca45436a07283e802/src/play.zig#L188 https://github.com/sdzx-1/ray-game/blob/9646bc3c0f1c11314aaf...
How do you understand such behavior?
- goless 1y agohttps://github.com/sdzx-1/polystate/raw/master/data/graph.png https://github.com/sdzx-1/polystate/raw/master/data/graph.pn... This is the state diagram combining two selects!
- goless 1y agoDue to my submission yesterday, this diagram can no longer fully accurately express the current state machine, but it can probably be used as an approximate reference.