Value semantics
In computer science, having value semantics (also value-type semantics or copy-by-value semantics) means for an object that only its value counts, not its identity.[1][2] If the concept is fully applied, value semantics implies immutability of the object.[3]
The concepts that are used to explain this concept are extensionality, definiteness, substitutivity of identity, unfoldability, and referential transparency.[4]
References
- ↑ "Some Basic QUESTIONS". http://www.velocityreviews.com/: velocity reviews. Retrieved 2011-06-17.
The important consideration for value semantics is that only the value of an object is significant, not its identity. So you can copy it (copy constructor or assignment) as much as you like, and any copy can be used in place of the original with no change.
- ↑ Daniel Elstner. "Re: extending Gdk::Region". http://mail.gnome.org/: GTK & GNOME Mailing Lists. Retrieved 2011-06-17.
What are value semantics? [...] It's an ad hoc shorthand for "value-type semantics", or "copy-by-value semantics".
- ↑ "Some Basic QUESTIONS". http://www.velocityreviews.com/: velocity reviews. Retrieved 2011-06-17.
An object represents an immutable value (vs. an object represents a system with a mutable state.) [...] Not necessarily, at least not in C++. I do like the idea that an object with value semantics can only be modified by the assignment operators, but this is far from the general case---std::string, for example, clearly has value semantics, despite a large number of mutator functions. (One can argue that this is a design error, but if so, it's still one we have to live with.)
- ↑ "Some Basic QUESTIONS". http://www.velocityreviews.com/: velocity reviews.
The important consideration for value semantics is that only the value of an object is significant, not its identity. So you can copy it (copy constructor or assignment) as much as you like, [...] One can eventually identify five different concepts that can be used to explain this notion in a more precise manner, these are: extensionality, definiteness, substitutivity of identity, unfoldability, and referential transparency.
This article is issued from Wikipedia - version of the Tuesday, January 20, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.