3 ms·
Yes the expression may not be precise enough, but the example should be accurate enough. 1, https://github.com/sdzx-1/polystate?tab=readme-ov-file#2-implementi
by goless 1y ago
Yes the expression may not be precise enough, but the example should be accurate enough.
1, https://github.com/sdzx-1/polystate?tab=readme-ov-file#2-implementing-and-reusing-selection-semantics https://github.com/sdzx-1/polystate?tab=readme-ov-file#2-imp...
This shows what composition means, and even complex nested selects are described quite precisely by type.
2, https://github.com/sdzx-1/polystate?tab=readme-ov-file#1-combining-checkpin-to-express-complex-logic https://github.com/sdzx-1/polystate?tab=readme-ov-file#1-com...
Yes, this effect can be achieved without using composite types. But if it is convenient and easy to achieve this effect through composite types, is it worth it?
- noelwelsh 1y agoI have to admit I'm not very interested in reading the code. I'm not likely to use this library so I'm more interested in a conceptual understanding than in the details that code requires. Regarding composition, there are at least three ways to compose FSMs: * Sequential: when one FSM finishes (reaches a final state) it transitions to the start state of another FSM. * Parallel: two FSMs transition in parallel from the same input * Nested: when a FSM reaches a certain state, another FSM starts responding to the input. When the second FSM reaches a final state, control returns to the original FSM. It would help your description if you were clear about the kinds of composition your library supports. The terminology of FSMs is quite consistent and well defined, so I think you should be able to use it to describe what the library does.
- goless 1y agoIs 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.zig 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.
- goless 1y agoFrom this perspective, do you think my previous description is accurate?
- mxkopy 1y agoThis sounds more like a product than a composition but I’m not sure. I think the parent is hinting to use established compcomp language. Sipser is a good read for this
- goless 1y agoI'm not sure if this is a new form of state machine. If you look at the code here you'll see that the select state uses some functions from the parameter state. https://github.com/sdzx-1/ray-game/blob/master/src/select.zig#L47 https://github.com/sdzx-1/ray-game/blob/master/src/select.zi... So you can see that the select state itself is incomplete, and the parameter state completes it. It doesn't seem to be any of the 3 described above. Perhaps it is reasonable to call it semantic composition.
- goless 1y agoHere I must mention the great advantage of the Zig language: it has the expressiveness of a dynamic language and the type safety of a static language.
- noelwelsh 1y agoYou keep using the term "semantic composition", which does not have any meaning for me. 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?