Operator overloading for non-value objects

Kevin Smith zenparsing at gmail.com
Tue Jan 14 16:22:58 PST 2014


On Tue, Jan 14, 2014 at 5:44 PM, Brendan Eich <brendan at mozilla.com> wrote:

> 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.
> Preview:
>
> js> 0L == 0
> true
> js> 0L === 0
> false
> js> typeof 0L
> "int64"
> js> 0UL == 0
> true
> js> 0UL === 0
> false
> js> 0UL == 0L
> true
> js> 0UL === 0L
> false
> js> typeof 0UL
> "uint64"
>

What about:

    0L == "0"

How is "===" defined for user-defined value types?  In terms of the T == T
overload?

    value class x {
        x == x () { ... }
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140114/812c1ba4/attachment.html>


More information about the es-discuss mailing list