Identity and References
A reference can be used to refer to an object with a specific identity. A reference contains the information that is necessary for the identity property to be realized in the programming language, and allows access to the object with the identity. A type of a target of a reference is a role. Typically, references are isomorphic to memory addresses. However, multiple such references can refer to the same object, if some form of address mapping is present (virtual addresses / page tables / memory segments).
Object identity is less useful as a semantic concept in environments or situations in which the structure of objects is not encapsulated, and two objects are considered to be the same object based on having identical properties, even if they are not actually the same physical instance (structural equivalence). However, object identity can nevertheless provide optimization. A function which tests whether two arguments are the same object can quickly short circuit to an affirmative answer if the two arguments have the same identity (are references to the same instance). Only if the argument are distinct objects do the individual properties need to be considered to determine equality, which is a more expensive operation. For instance, bignum integers may be heap-allocated objects such that two bignums are considered to be the same if they represent the same number. It would be a waste of machine cycles in the equality function not to take advantage of the discovery that the two arguments being compared are references to the same bignum.
Read more about this topic: Identity (object-oriented Programming)
Famous quotes containing the words identity and and/or identity:
“The adolescent does not develop her identity and individuality by moving outside her family. She is not triggered by some magic unconscious dynamic whereby she rejects her family in favour of her peers or of a larger society.... She continues to develop in relation to her parents. Her mother continues to have more influence over her than either her father or her friends.”
—Terri Apter (20th century)
“Every man must define his identity against his mother. If he does not, he just falls back into her and is swallowed up.”
—Camille Paglia (b. 1947)