korken89 / smlang-rs

A State Machine Language DSL procedual macro for Rust
Apache License 2.0
202 stars 28 forks source link

Question on on_entry and on_exit for states #82

Closed dkumsh closed 1 month ago

dkumsh commented 2 months ago

Hi, this feature has been recently added and I wanted to discuss it:

The current code base implements the following order for transitioning from State1 to State2:

  1. Transition action is executed.
  2. on_exit hook of State1 is called.
  3. on_entry hook of State2 is called.
  4. The state machine transitions to State2.

I think this order should be changed to the following for better consistency and integrity:

  1. on_exit hook of State1 is called.
  2. Transition action is executed.
  3. The state machine transitions to State2.
  4. on_entry hook of State2 is called.

Here are my points to support this:

ryan-summers commented 2 months ago

The reorder sounds reasonable to me. They're pretty fresh freatures so I don't think anyone would be relying on the exact ordering yet personally.

dkumsh commented 2 months ago

Sounds good, I will add it to my active PR.

dkumsh commented 2 months ago

Pushed to the active PR