
David Abrahams wrote:
"Andreas Huber" <ah2003@gmx.net> writes:
David Abrahams wrote:
Yes, but only at the cost of making the current interface (and implementation) more complex (we'd need to have at least a separate exit() function, right?).
No. At the moment we're just talking about whether A1 is justified. Whether or not exit actions should use destructors is a separate question.
Is it? In the current design the state machine object owns the state objects (it does so for good reasons). How can you destruct the state machine object without destructing the state objects (and thus inevitably also exiting them and terminating the state machine as a result)?
You're still collapsing separate concepts.
The current implementation does. I don't think I did with the above reasoning.
Conceptually, state (machine) destruction is independent of state machine termination.
Yes, conceptually. However, since in the current implementation the state machine destructor will inevitably destruct all the state objects, it is also inevitable that they are all exited (which is equivalent to terminating the state machine). That's why I said that I'd need to change the state interface to separate state machine termination (which calls exit() on all states and destructs them afterwards) from destruction (which only destructs the states). Regards, Andreas