Follow

@alcinnz I will now rant about the equality.

Structural vs reference:
In computers(and one might even argue in real world in general) everything has value(structural) semantics of equality. Reference semantics can be achieved by the type systems, abstracting away machine pointers, though the concept is applicable beyond just machine pointers, you'll often find yourself in the exact same situation when using an object of any type as an ID/handle/key in some data structure.

Equivalent representation:
Again solved by a type system.
The case of real numbers is a distraction, real numbers are not representable in computers. Floating point numbers are an approximation. Equality is(can be) well defined on floats, and the common problem with those is not in equality checks, it is in the imprecision of arithmetic operations (such as multiplication in 10 * 0.1), which will cause confusion in a lot more places than just equality if you are unaware of it.
More to the point of the representations, rational numbers 2/4 and 1/2 (the idea applies to floating -0 or 0 too) can be equal or not dependent on how you view them. In any given context you might want to work with them as just a pair of numbers or ratios or anything else they are capable of modelling. The solution at the end of the article doesn't even address this, but type systems do.

Intentional vs. Extensional Equality:
People know they can't solve the halting problem, so they don't try to. Also in most sane languages functions are not mutable so the previous examples and shortcomings with reference semantics don't apply.

In sufficiently complex and abstract systems, separate equality comparisons can be a pain to keep track of. You need something to help you with that and also allow expressing you intentions more clearly in interfaces, not forcing people to read implementations to understand which equality might be used where. You need a type system that is capable of abstracting away both.
In simple concrete cases, I can't imagine one ever needing to switch between the two types of equality back and forth. Any such switch will require a switch in mindset, therefore a type cast/conversion would also be affordable.

In my experience any confusion with this doesn't come from people wondering weather reference or value semantics are used for any given type and guessing it wrong, the confusion comes from people not even considering that, and not having a good understanding of the difference, that is, if given a choice, wouldn't even know which equality they want to use.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.