When generating the code for a StateChart the generated code is likely to not have the same lexical / hierarchical structure as the original StateChart. That is, if A is a state, and A1, A2, ... are substates of A, it is not likely that the code for A1, A2 and so on will be literally nested inside the code-block for A. That might happen if the target language supports such a thing, but many languages do not.
However, from the standpoint of the programmer it is a great convenience to be able to declare and assign to a variable in A (a StateVariable) and have that variable and its value be known to A1, A2, etc. And if A1 declares a variable of the same name, then within A1 the name should refer to the variable declared inside A1.
But the implementation of this concept is not quite straight-forward. A StateVariable must be visible across all of the code-blocks for the state, and sub-states, where it is defined. In practice this means that must be an accessible instance variable (if the target language is object oriented), or a static variable (for C or for any implementation that does not rely on object-orientedness).
This is what I mean by LexicalScoping in the context of StateCharts.
-- DaleBrayden - 16 Jul 2002
Current Rev: r1.2 - 12 Feb 2003 - 23:50 GMT - DaleBrayden, Revision History:Diffs | r1.2 | > | r1.1