Operator overloading for non-value objects

Brendan Eich brendan at mozilla.com
Mon Jan 13 08:28:57 PST 2014


Anne van Kesteren wrote:
> On Mon, Jan 13, 2014 at 3:40 PM, Brendan Eich<brendan at mozilla.com>  wrote:
>> >  We want to keep the relatively few invariants in the language that we have.
>> >  Why is it so important to have == for (mutable) URLs?
>
> The alternative is rather ugly. You don't want to sometimes write ==
> (value objects) and sometimes write .equals() (non-value objects,
> method name won't always be the same, e.g. we have isEqualNode()
> already).

The point is you *do* want == to mean, for two values, something that's 
true on the next line and the one three after that, no matter what 
mutations to the heap might occur (note: I'm not talking about rebinding 
variables).

At least, some people do. If we can't agree, the 
conservative-language-design outcome will still not let mutable objects 
be sometimes==.

I know, other languages allow this. The experience in those languages 
seems mixed to bad. Anyway, that's my view. What do others think?

/be


More information about the es-discuss mailing list