Operator overloading for non-value objects

Kevin Smith zenparsing at gmail.com
Tue Jan 14 10:41:16 PST 2014

> In JS world we are "use to" compare via === so that when == is used
> instead we are usually in "power user land", I don't see any conceptual
> shenanigans in doing something like above code.
Only power users use "==" because it has weird conversion semantics that
are hard to internalize.  "==" doesn't map to any simple relational
concept, certainly not "equality":

    ({}) == "[object Object]"; // true

So if a user is going to overload "==", are they going to maintain those
bizarre semantics?  If so, then crazy-pants.  If not, then it seems like we
have introduced a hazard into code that is generic with respect to the
types of operands to which "==" is applied.  Sometimes crazy conversion
semantics, sometimes sensible equality semantics.

I'll stop there, because I don't know the details of the proposal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140114/67220adb/attachment.html>

More information about the es-discuss mailing list