Comparison
ReferencevsValue semantics
Reference
Defined by the difference stated below.
Value semantics
you passed it to a function, the function changed it, and your copy changed too — or it did not, and you had to know which.
Whether assigning or passing something shares one object or produces an independent copy. It decides whether aliasing is possible at all, and therefore whether defensive copying, immutability and thread-safety are concerns in a given piece of code. Most mainstream languages are reference-semantic for objects and value-semantic for primitives, which is exactly enough inconsistency to catch people out at a boundary.
Full entry →The difference
Whether assigning or passing something shares one object or produces an independent copy. It decides whether aliasing is possible at all, and therefore whether defensive copying, immutability and thread-safety are concerns in a given piece of code. Most mainstream languages are reference-semantic for objects and value-semantic for primitives, which is exactly enough inconsistency to catch people out at a boundary.
Entry: Reference vs value semantics →