Le 02/04/2011 21:30, Brendan Eich a écrit :
> On Apr 2, 2011, at 12:16 PM, Brendan Eich wrote:
>
>> You must mean only in the cases where typeof a == typeof b, then a == b <=> 
>> a === b, and === is an e.r. But that does not mean == is an e.r.
> Forgot typeof a == "object" above, to be precise.
Indeed, I considered == to be an e.r. only in the contexts of objects.
Sorry for the inaccuracy. Behavior when one side isn't an object would
remain the same.


>> For mismatching types, == is not transitive, so not an e.r. Also, for NaNs 
>> it is not reflexive (neither is ===).
> The desire for < (partial order) as well as a true e.r. is strong, though, so 
> thanks for raising this issue.
>
> The big question remains: Is some modular opt-in to better == (and <) for 
> objects worth the complexity?
> What developers want, IMHO, is not Object.create and a specific object
> o to pass as a member of an existing e.c., in which to create a new
> object. That is tedious and painful, it requires _a priori_ arrangements.
>
> Rather, many developers wish == would work at least like so (same for
> <): [1, 2] == [1, 2]. Hence the tuples and records ideas in
>
> http://brendaneich.com/2011/01/harmony-of-my-dreams/
>
> whereby #[1, 2] == #[1, 2] and #[1, 2] < #[1, 3].
>
> More could be done, for sure. If Array users, say on a module by
> module basis, could "opt in" to better == and < semantics, that might
> be worth the trouble of adding such opt-in new operators.
Are there other use cases than this one (#[1,2]...)? If not, then tuples
are the right solution and it leaves the room for objects to define
their own ==.
I'm surprised by the idea that == could be defined on a per-value
comparison basis on objects (Array as you give it as an example). It
doesn't make the relation last throughout the program lifetime (which is
what I was trying to do and requires a priori arrangements). I would
expect an equivalence relation to last throughout the program. Like ===
does.
With the defintion I tried to give to ==, I admit that it does not open
the door for a < to be defined on objects.

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to