-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guard language and general question #23
Comments
I think my confusion around guards is because transitioning from the same state, with the same event but different guards isn't legal:
but if you look at the boost action-guards
|
@x37v, I looked at both of your comments and would like to summarize the 3 options you touch on.
The issue I see here will be around error checking. The main reason to NOT allow 2 transitions with the same starting state and event and different guards is that if both guards are true, you can have can have a transition table with a conflicting output state. Given that this crate was originally designed to mimic the boost syntax, I think it makes sense to mimic it where features overlap. This syntax basically allows for an event to be re-used with different logical combinations of guards, forcing the user to explicitly specify a mutually exclusive transition. |
Yeah.. I have a fork that allows for this and there is an implicit behavior that the first valid transition takes precedence (as it is just a |
@x37v, why not do a PR? Its new syntax that is useful that is a user is not required to use. |
I do think the Rust style match guard is the most elegant approach, although definitely not what boost uses. |
it is quite a departure: https://github.com/x37v/smlang-rs |
Multiple transitions with same state/event combination but different guards is important for versatility. Otherwise a user needs to expand what a guard could handle into separate events, which can lead to code duplication. |
the README states:
But in the examples we see that guards return
Result<(), ()>
.. functionally I guess they're the same except I see that you can return a custom error instead of()
. But, re my question below, depending on the goal of a guard, anErr(())
might feel a little wrong?I'm wondering what the general idea for a guard is? I'm assuming it is a way to encapsulate some functionality so that
Event
data can be evaluated and instead of havingButtonSevenDown
you can haveButton { down: true, index: 7 }
and evaluate the a guardbutton_down
,button_seven_down
orbutton_seven
?The text was updated successfully, but these errors were encountered: