|
|
|
|
|
by goless
364 days ago
|
|
Is there a way to combine: Higher order finite state machines that require other states as parameters to work. https://github.com/sdzx-1/ray-game/blob/master/src/select.zi... The select, inside, and hover states here are all high-level states, and all require two state parameters. And these three states form a small state machine for handling mouse interactive selection. Can I think of this way of using higher-order state machines as a kind of composition? A semantic composition. |
|
Take function composition, which is perhaps the best known example of composition. Let's say we have
f(x) = x + 1
g(x) = x * x
The composition (f o g) = g(f(x)) could be called a "semantic" composition because the result has the semantics of the two functions (it increments then doubles). So what does your use of the term actually mean?
In general I feel you need more precision in your description. There is standard terminology for finite state machines and for programming languages that I think you could use. Take, for example, your statement "all require two state parameters". I think these are not value level parameters, but type level parameters. This is an important difference, and you should mention it.
Going back to FSMs, there are several ways you can encode a FSM in a typed programming language. For example:
1. A FSM is a type constructor parameterized by the type of states. This means the FSM cannot transition to states that are not of the correct type, but it does not otherwise constrain transitions.
2. States themselves are type constructors parameterized by the type of states they can transition to. This adds more constraints (and requires more complex types) than the approach above.
Do you see the difference between these and hence the need for clarity and precision in descriptions?