RE: Grandparent <state> for <final>

The other interesting edge case to consider is what if you have parallel regions inside one of the states inside the other parallel region.  If there is a final inside a state inside the most nested parallel region would that propagate up the tree to the enclosing parallel state and the higher level super-parallel region or would it only propagate up in a more limited fashion? This complexity is easier to resolve if you take the more limited and less expansive view of what causes things to be in a full final state.

From: Jim Barnett [mailto:1jhbarnett@gmail.com]
Sent: Wednesday, June 28, 2017 4:05 PM
To: www-voice@w3.org
Subject: Re: Grandparent <state> for <final>


Interesting case.  I'm pretty sure that:

1) The current language was what the group wanted (i.e., it's not an error)

2) We never discussed this case.

However, to expand a bit further:  suppose we add a <final> child to state p0_s0 (i.e. a sibling state to p0_s0_s0).  In that case we wouldn't want entering p0_s0_s0_f0 to put the parent p0_s0 in a final state - only entering its direct <final> child should do that.  The current language forces authors to be explicit about final states, and is easy to understand, but in examples like yours it can lead to somewhat counter-intuitive results.   If we try to get 'final-hood' to be inherited upward, but for the inheritance to be blocked by the presence explicit higher-level <final> states, the definition gets very complicated.

- Jim

On 6/28/2017 6:10 PM, Gavin Kistner wrote:
A couple years ago I wrote a Lua interpreter for SCXML[1]. Stefan R. just filed a bug with it[2]. At the core of the issue is whether the following SCXML parallel should be 'in a final/done state' after being entered:

    <parallel id="p0">
        <state id="p0_s0">
            <state id="p0_s0_s0"><final id="p0_s0_s0_f0"/></state>
        </state>
        <state id="p0_s1">
            <state id="p0_s1_s0"><final id="p0_s1_s0_f0"/></state>
        </state>
    </parallel>

My interpreter fires "done.state.p0_s0_s0" and "done.state.p0_s1_s0". However, it does not cause "p0_s0" or "p0_s1" to be considered in a final state, and therefore does not consider the parallel to be in a final state.


On the one hand, this clearly looks like a bug in my interpreter against how I would *expect* the specifications to handle this situation. On the other hand, the specifications+errata only appear to cover situations where a <parallel> is exactly a *grandparent* of the <final>, not any further ancestor.


Section 3.7 of the spec says:

"When the state machine enters the <final> child of a <state> element […] generate the event done.state.id [...] where id is the id of the parent state. Immediately thereafter, if the parent <state> is a child of a <parallel> element, and all […] other children are also in final states […] generate the event done.state.id where id is the id of the <parallel> element."

This only covers exactly the parent of the <final>, not any grandparent <state> or great-grandparent <parallel>.

Further, the pseudo-code for Appendix D explicitly only handles one level at the end of enterStates(), and also only handles one level for the definition of isInFinalState().


If Stefan (and my) belief about how this should behave is correct, then (a) the prose in 3.7 needs to be modified via errata, and (b) the isInFinalState() pseudo-code should be modified to recurse, and (c) we need to discuss whether grandparent <state> also fire "done.state.xxx" events when their child state becomes in a final state, and if so, modify the pseudo-code in enterStates() to do so.

If we're wrong—if grandparent states do not get this event fired, are not considered in a final state, and if the parallel in the example above should also not be in a final state—I'd be very interested to hear some arguments for this.

[1] https://github.com/Phrogz/LXSC

[2] https://github.com/Phrogz/LXSC/issues/1



--

(-, /\ \/ / /\/

Received on Thursday, 29 June 2017 22:59:26 UTC