[whatwg] link.sizes and [PutForwards=value]

> Cameron McCormack:
>>> The two Location objects stringify to the same thing, but are not 
>>> ==.  I think
>>> this can be confusing.
>
> Ian Hickson:
>> Can we overload equality for objects?
>
> No, not within the confines of ECMAScript.

I do agree here with Cameron. This could cause inconsistency issues, 
some object would be compared according to pointer like approach, some 
object would be compared according to toString()/valueOf() approach; 
some objects might represent the same data when stringified, yet be 
different ([object Object]).
The fact, that programmer does not know that window.location is Location 
object, not string should be no excuse here. Setter of this object can 
accept string, that is fine, but getter should return always the same, 
not sometimes string, sometimes object...
if

xw.location == yw.location
are the same based on string comparison, we would introduce type coercion to comparison with already the same type on both sides, heh?.
And at last, what should
var x = xw.location
do? what is the type of x? String? it makes no sense at all. Object? fine, but then how come sometimes getter returns object (in assignments) and sometimes string (in comparison).
ECMAScript defines no operator overloading, and we should not introduce one arbitrary because someone does not read spec, does not test, does not use browsers development tools, etc.

Brona

Received on Friday, 20 January 2012 20:49:38 UTC