Virtual functions could have multiple definitions, for different
object states.
The prototype of a virtual member function could have an optional
reserve word "for" followed by a comma-separated list of state names.
The statement:
virtual using <state>;
would put the object in the state named <state>. The statement:
virtual using 0;
would put the object back in the default state. The expression:
virtual <virt-mem-funusing <state>
would return true if, at the point of execution of the expression, a
call to the virtual member function <virt-mem-funwould execute the
definition of the function valid for state <state.
I think this feature would have many uses. For example, if the read
member function was called for a closed file, this could trigger a
version of read that would throw an exception.
A feasible implementation would be to have multiple v-tables, one
appropriate for each state. State changes would involve changing the
v-pointer(s). This would get complex with in large inheritance
trees. The function to change the v-pointer would itself have to be a
hidden virtual function.