Open suspiciousfellow opened 3 years ago
What's wrong with overloading ==
and !=
? If you can change what that operator does, its current behavior isn't going to be a problem. The ====
operator you propose, apart from being excessively long, makes the impression of being more strict than ===
, which would be very misleading if you overload it to be less strict.
The issue with using the existing operator isn't its behaviour when overloaded - it's its behaviour with existing types (the issues here are well known).
Point taken on the potentially misleading impression though. Not sure what to suggest there, not enough symbols on the keyboard...
not enough symbols on the keyboard...
Maybe =@=
, =#=
, =$=
, =?=
? The rationale behind using a special symbol between the =
s is to avoid ambiguity with assignment ops
Most linting rules, good practice guidelines, etc attempt to avoid
==
due to its confusing semantics.Overloading the strict equality operator is out because it's going to break stuff.
How about a new operator
====
that acts like===
with the exception that it can be overloaded for two objects with same prototype?Thus example in the PR would become