3 ms·
The notion of value objects reminds me of certain types in Common Lisp, dating back to the definition of the language in the 1980s. The numeric and character t
by pfdietz 4y ago
The notion of value objects reminds me of certain types in Common Lisp, dating back to the definition of the language in the 1980s.
The numeric and character types in Common Lisp are immutable value types. The standard says they may be copied at any time, so the object equality operator (eq) may or may not return true on them. There is a separate equality operator, eql, that performs value equality on value types (so two numbers whose value is the same integer, even if they are bignums with a representation stored on the heap, will return true when compared with eql.) Eql has the same meaning as eq on types that are not immutable value types.
While this is not standardly possible in CL, it would be nice if users could extend operators like eql with new methods, thereby defining new immutable value types.
A nice thing about these value types is they play well with distributed computation or with saving of values to offline storage.