[erlang-questions] gen_statem state enter call and changing t oanother state

Vlad Dumitrescu vladdu55@REDACTED
Mon Jun 11 18:46:04 CEST 2018

On Mon, Jun 11, 2018 at 5:47 PM Frans Schneider <fchschneider@REDACTED>

> On 06/11/2018 05:15 PM, Raimo Niskanen wrote:
> > But there are still some hairy semantics to get right:
> > * If changing states in state_enter call hops more than once - what
> should
> >    OldState be after the first state_enter call?  I.e how much of a state
> >    change should changing states in the state_enter call be regarded as.
> >    As the gen_statem code looks now it seems to be easier to retain
> >    the original OldState and not regard the state change as complete
> until
> >    the final state of the state change has been deduced.
> Yes, I would expect a cascade of state enter calls with OldState
> reflecting the states it goes through.

I am not a state machine expert, so maybe I am misunderstanding. If we
allow jumping to arbitrary states from state_enter, isn't it like there is
another state embedded there?

One of the advantages of state machines is that it's easy to see from the
code where the continuations are. One can no longer tell from examining the
source state what states follow it, but one has to examine the state_enter
of all these first.

Isn't it cleaner to just separate this complex state into several simpler
ones? Or am I missing something?

best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180611/4a046570/attachment.htm>

More information about the erlang-questions mailing list