Operator overloading for non-value objects
brendan at mozilla.com
Tue Jan 14 14:44:55 PST 2014
Kevin Smith wrote:
> I'll stop there, because I don't know the details of the proposal.
Allowing value objects (and perhaps mutable object) to define operators
means giving up some invariants, similar to proxies which can have
incoherent has/get etc.
So I'm not sure what you are waiting for. A badly written user-defined
value object? Those may be easy to cough up in order to complain about
extensibility, but the whole point of value objects is to avoid hardcoding.
If you want an int64 spec/impl to evaluate, that'll take a bit longer.
js> 0L == 0
js> 0L === 0
js> typeof 0L
js> 0UL == 0
js> 0UL === 0
js> 0UL == 0L
js> 0UL === 0L
js> typeof 0UL
Someone who insists on using === only can convert from one numeric type
js> int64(0) === 0L
Of course you have to beware of values that convert lossily, but for 0,
1, ... N, we have == and I think it ought to work.
More information about the es-discuss