Closed SanderMertens closed 7 years ago
The DECLARED
state is currently only used to indicate whether an object is orphaned or not (other objects are always declared).
Therefore, DECLARED
state can be removed, and replaced with a orphaned
bit in the object header.
Currently, objects have a state mask that tracks where they are in their lifecycle. This mask includes the following constants:
DECLARED
,VALID
,DEFINED
,DESTRUCTED
.The
DECLARED
mask is assigned to all declared objects (all objects except orphaned objects). TheVALID
mask is assigned to all objects for which the initializer was success and that are not invalid. TheDEFINED
state is assigned to all objects that have been defined.DESTRUCTED
is assigned to objects that have been deleted (but not yet deallocated).The semantics of the
VALID
state are not straightforward. It is a mix between successful init and validity of the object value. In practice, a user would have to check for bothDEFINED
andVALID
to determine whether the object value can be interpreted.These two states can be merged into one state, that simply indicates whether object value is valid or not. The value of an object is not valid right after declaration, but will become valid after the object is defined. If a
construct
orvalidate
fails, or theinvalidate
function is called, the VALID flag will be removed.