状态机:与转换相关的行为期间的异常

state machine : exception during a behavior associated to a transition

一个行为可能与一个转换相关联,这就是效果。记得看过一个effect和一个guard应该是无副作用无异常的

但是看了规范的2.5版本,我又没有找到。

我错了吗?如果不是,如果在执行期间出现异常怎么办?

一个解决方案是根据效果的结果定义一个守卫,但这可能吗?事实上,我从来没有这样做过。

页。 358:

♦ guard : Constraint [0..1]{subsets Namespace::ownedRule} (opposite A_guard_transition::transition) A guard is a Constraint that provides a fine-grained control over the firing of the Transition. The guard is evaluated when an Event occurrence is dispatched by the StateMachine. If the guard is true at that time, the Transition may be enabled, otherwise, it is disabled. Guards should be pure expressions without side effects. Guard expressions with side effects are ill formed.

页。 375:

Because a transformation or selection Behavior is used while offering tokens to the target node, it may be run many times on the same token before the token is accepted by the target node. This means the Behavior cannot have side effects. It shall not modify objects, but transformations may for example, navigate from one object to another, get an attribute value from an object, or replace a data value with another.

您应该阅读 14.2.3.9.1 The run-to-completion paradigm 部分,其中详细解释了转换是如何发生的。简而言之,如果在转换行为执行期间发生异常,则不会执行此转换。