-
Notifications
You must be signed in to change notification settings - Fork 31
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
Is there support for multiple guarded transitions for a state and a triggering event ? #71
Comments
If the initial state and triggering event are identical, I do not believe we support multiple ending states based on different guards. You would have to use a different event type to accomplish this instead. Can you clarify what you're looking to do exactly? |
Something like this: Here is one of my examples: If the message I got is not the first message, I stay in the same state and ignore the fragment (as I need to wait for the first fragment) Multiple transitions in a given state and for a given triggering event is exactly what the guards were designed for, as it described in the Wipkipedia article I am refereeing. One guard per state/trigger works more like an assertion rather than a guard Here is for example you can see a UML visualisation of how guards are used. I think full support of this would be a valuable extension to smlang . |
Interesting that BoostSML indeed supports this. I'd be happy to review a PR for it, but this definitely feels non-trivial to add.
No, I don't believe this is yet implemented in
To implement this, you would need to parse the syntax for it in the proc-macro and update the generated code logic. You'd also need to implement code within the proc-macro to check that the guard logic are non-overlapping implementations as well, which could be somewhat complex to verify. I'd recommend looking at some existing and previous PRs to get a feel as to what the changes look like, for example #66 By the way, I don't see how your example would require this. It seems like you could probably implement this with different state transitions to work around this, but that's just my take. |
Thanks for you reply. I made a change on my local clone. Indeed it is not a simple change. |
I have created a draft PR for a review : #72 |
Current implementation only allows single function guards. |
Hello, could someone please review the pull request at their earliest convenience? Thank you! |
@ryan-summers Tanks for providing the review! |
Is there support for multiple guarded transitions for a state and a triggering event ?
As it is described here,
the guards should enable/disable transitions based on the value of the extended variables and event parameters.
I would expect that guards should allow transitions from (state,event) to different states, same way as it works in Boost SML and many other state machine implementations.
The article referenced above says:
In extended state machines, a transition can have a guard, which means that the transition can "fire" only if the guard evaluates to TRUE. A state can have many transitions in response to the same trigger, as long as they have nonoverlapping guards; however, this situation could create problems in the sequence of evaluation of the guards when the common trigger occurs. The UML specification[1] intentionally does not stipulate any particular order; rather, UML puts the burden on the designer to devise guards in such a way that the order of their evaluation does not matter. Practically, this means that guard expressions should have no side effects, at least none that would alter evaluation of other guards having the same trigger.
Is there support for multiple guarded transitions for a state and a triggering event ?
If yes, could you please show how to do it, otherwise would it be possible to implement it?
The text was updated successfully, but these errors were encountered: