Equality

Doug Lea dl at cs.oswego.edu
Sat Dec 19 18:45:41 UTC 2015


On 12/19/2015 11:38 AM, Brian Goetz wrote:
>> Anyfy equals, and adjust default implementation of boolean T.equals(any x)

> "any" is not a type; it is a modifier that affects the domain of type
> variables.

OK. I should have first asked whether there are plans to allow forms like:
   <any T> boolean equals(T x)
including as sugar for some superation-like construction.

It would be nice to further abbreviate as "(any x)"
but probably syntactically impossible. But still convenient in
pseudocode discussion.

> So we don't have (and I think we don't want) a meaning for
> equals(any x).

The equals method is special because it is the only defined Object
method that can interact with Values world, and vice versa.
So making it parametric across them seems necessary,
even if it requires some special JVM magic.


>> I still think that doing something like this removes the need
>> to specially deal with Collection.contains and related methods.
>
> I don't see it yet; those signatures are still currently contains(Object), which
> isn't appropriate for value types.  So we have to do *something*.

Right. I agree that the signature must compatibly change,
but not necessarily that anything else does.

-Doug



More information about the valhalla-spec-experts mailing list