Proposal for new floating point and integer data types

Brendan Eich brendan at mozilla.com
Tue Oct 29 10:04:19 PDT 2013


Tristan Zajonc wrote:
>
>     if (mutMatA == mutMatB) {
>         accidentallyMutate(mutMatA);
>         assumeStillEqual(mutMatA, mutMatB, data);
>     }
>
>
> Is this bug related to operator overloading?  It seems just the nature 
> of the beast with mutable reference types. Pretty much all JS matrix 
> libraries today use:
>
> if (mutMatA.equals(mutMatB)) {
>     accidentallyMutate(mutMatA);
>     assumeStillEqual(mutMatA, mutMatB, data);
> }
>
> which I assume would suffer from the same bug?

You bet, but special forms exist to have primitive semantics, which can 
be meta-programmed only in certain ways (we try to preserve certain 
invariants). With .equals, anything goes. With == where both operands 
are object references, there has been an invariant. Allowing operator 
customization to break that invariant might be worth the downside, but 
it deserves discussion.

/be


More information about the es-discuss mailing list