Object invalidation refers to the marking of an object as invalid, preferably in a controlled way so that further access to the object results in controlled failure (rather than UndefinedBehavior). In some ways, a form of TypeMigration.
Can be implemented in several ways:
By the class designer:
- Have a "valid" flag in the object, and an IsValidMethod. The DestroyMethod (or whatever means are used to invalidate the object) clear this flag; all other methods check the flag via the IsValidMethod and fail if it returns false.
By the language implementer:
- Change the VeeTable pointer (or whatever magic field contains runtime type information) to null or some other distinguished value indicating a DestroyedObject? (which might be a type recognized by the type system).
- If TombStones are used; change the TombStone to point to a DestroyedObject?.