Value semantics explained
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] Immutable objects have value semantics trivially,[3] and in the presence of mutation, an object with value semantics can only be uniquely-referenced at any point in a program.
The concepts that are used to explain this concept are extensionality, definiteness, substitutivity of identity, unfoldability, and referential transparency.[4]
Notes and References
- Web site: 2011-06-17. velocity reviews. Some Basic QUESTIONS. 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. .
- Web site: 2011-06-17. Daniel Elstner. GTK & GNOME Mailing Lists. Re: extending Gdk::Region. What are value semantics? [...] It's an ad hoc shorthand for "value-type semantics", or "copy-by-value semantics"..
- Web site: Some Basic QUESTIONS . 2011-06-17 . velocity reviews . 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.).
- Web site: Some Basic QUESTIONS. 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..