On Apr 17, 2011, at 7:52 AM, Adam Stankiewicz wrote:

> Hello everyone,
> 
> My idea is to disallow overwriting of === operator, and make 'compare'
> operator implement == instead. Why?
> 
> 1. === means for me that two variables have reference to the same
> object, so there is no point of overwriting it. Many programmers would
> be confused.

The reason === comes up with value types/proxies is the goal of supporting 
decimal and other number types, where 1.1m === something_computing_fresh_1_1m() 
must be true.

Decimal in IEEE754r also wants NaNm !== NaNm, and -0m === 0m.


> 2. == always caused problems, above change gives it opportunity to
> return to grace.

I'm always in favor of adding ways for that which fell from grace to be 
redeemed over time, by developer choice, without breaking the old form if 
possible. This is a recurrent theme.


> You don't know if they are the same object? Use ===. Don't know if
> these objects are the same, but only in eyes of programmer? Use ==.
> Think about == or < as semantical operators, and === as hard-cored
> is-the-same-object function.

The problem is objects in JS are reference types currently. Value types or 
proxies would be objects that, by virtue of being shallowly frozen, say, could 
be compared by reference or property values. This needs care in spec'ing since 
the shallow vs. deep freezing may not cover value types with deeper structures 
that nevertheless want to be compared by value. Deep comparison is possible of 
course, just more work.

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to