
David Abrahams wrote:
I think a foundation for a decision is not flimsy when the behavior in question has proved to be useful in practice. So far nobody, who seems to have experience with non-trivial FSMs, has doubted that it is useful to terminate a state machine when it is destructed (my assumption A1).
I don't doubt that it's often useful. I also think it is surely sometimes highly undesirable.
I'd be interested in examples.
If you remove A1, the "useful" behavior is trivial to achieve without transforming the FSM, so it seems that a design without A1 is both more flexible and more orthogonal.
Removing A1 means complicating the interface (see my other post regarding exit()).
BTW, as pointed out by someone else the user *does* have a choice. If she happens to have an exit action that she'd rather not have executed upon destruction then she can always transform the machine part in question such that her action is executed as part of a transition action instead (I would consider it a design error not to do so).
Why?
Every Moore machine (an FSM that has only entry and exit actions) can be transformed to a Mealy machine (an FSM that has only transition actions) and vice versa.
Why require a transformation when it's not neccessary?
Because I very much believe that such a transformation is necessary only in very few cases (I've never encountered one) and I don't want to complicate the interface and potentially also pessimize the implementation for all users just because of those few cases. Regards, Andreas