Define default and primitive equality
jakearchibald opened this issue · 0 comments
My assumption so far has been that 'immutable' things are equal to another thing of the same type if the data within is identical, otherwise equality is based on whether they're pointing to the same instance of a thing.
So, null is null, true is true, but an empty list is not equal to an empty list unless both lists are the same list instance (as in, a mutation of one would be reflected in the other).
Maybe a primitive type definition should be created that indicates that primitive types are immutable, and equality is based on identical data (which may be expanded upon in the definition of a particular primitive type, as is currently done with strings). This would also be a good place to document why it's correct to say "the empty string" but incorrect to say "the empty map".
This would also mean specs could introduce their own types with primitive-like behaviour.
It also feels like tuples should be a primitive type rather than a data structure, since they're immutable and "hello"/"world" is equal to "hello"/"world".