2 ms·
Is reference equality ever useful in itself, in a high level language? Of course reference equality is a straightforward optimization for structural equality,
by jerome-jh 7y ago
Is reference equality ever useful in itself, in a high level language?
Of course reference equality is a straightforward optimization for structural equality, as mentioned in the post. But it is not required to make it visible to the programmer.
Reference equally is mandatory for the garbage collector. Again it may not be visible to the programmer.
Finally there is the case of two data structures sharing a reference to a single instance of some data. Usually that is a bad idea if the pointed to data is mutable, and often makes the program leaky.
The paper reads: "So reference equality is a sensible default in a language which supports mutation.". Is it not a bad reason to support reference equality?