摘要 |
A system and method for representing a state of an object by the object's type. A method includes receiving a request to change a state of an object. In various embodiments, the object may correspond to an instance of a class. Responsive to the request, the method includes changing the type of the object from a first type that corresponds to the first state to a second type that corresponds to the second state. There is no explicit representation of the state of the object included in the object. Rather, the object type is used to represent its state. Changing an object's type includes creation of a new object that corresponds to the second type, and storing the new object at the same location in memory wherein the original object was stored. A memory allocation is not performed as part of the creation of the new object. |