> 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.

If 1.1m was defined as singleton proxy, then === would work correctly,
because both 1.1m and give_new_1_1() return the same proxy. Creating
new proxy each time would cause memory overload, especially
considering decimals. Additionally in JS something like 2 === new
Number(2) returns false, so in my opinion it is not good idea, to let
programmer define ===, even for decimal proxies. And if we let
programmer create fresh 1_1m objects there would be no way to
distinguish them, just because of trapped ===.

> 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.
Exactly. === should be used only as reference-comparator (primitive
types are somehow singletons). Creating trap for == gives programmer
choice what type of comparison (even deep) use for his object.

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

Reply via email to