3 ms·
A couple other counterexamples to > "Records with the same internal data ARE equal by default" Floats: floating point equality tests between two floats of the
by elihu 6y ago
A couple other counterexamples to
> "Records with the same internal data ARE equal by default"
Floats: floating point equality tests between two floats of the same value or testing equality with itself is generally "true" with the exception of NaN (i.e. "not a number") values. Testing if NaN == Nan is "false" according to the IEEE [1]. (Probably not all languages follow IEEE's recommendation.)
Functions: some functions are trivially the same, and some functions are trivially different, but deciding whether arbitrary functions (for instance, f(x) { x + x } and f(x) { 2*x } return the same values and have the same side-effects for all possible inputs is generally not something a compiler should be expected to do. So any record with a function as a field can't really be tested for equality.
[1] https://stackoverflow.com/questions/38798791/nan-comparison-rule-in-c-c https://stackoverflow.com/questions/38798791/nan-comparison-...