3 ms·
> IMO, any language with a type system should enforce comparisons only between those types (or derived types) There are languages with a type system that have
by zajio1am 5y ago
> IMO, any language with a type system should enforce comparisons only between those types (or derived types)
There are languages with a type system that have universal type (and all types are derived from it), in these languages it make sense that "5" == 5 is defined and false.
- int_19h 5y agoA universal type doesn't necessarily have to be arbitrarily comparable between instances. The strictly correct response to "5"==5 really is "not comparable"; it's just a question of how you choose to surface it. One popular choice is to define the equality operator as returning false if the operands aren't comparable - but then you have to do the reverse for inequality, which is far less obvious.