Equality

Brian Goetz brian.goetz at oracle.com
Wed Dec 23 17:26:05 UTC 2015


> ....there could be a special interface:
>
> public interface Any<any T extends Any<T>> {
>     boolean equals(T x);
> }

This is exactly the current thinking -- though we don't call it Any, we 
call it Objectible.

> ...implemented by Object:
>
> public class Object implements Any<Object> {...}

We were thinking that this would be Object implements *raw* Objectible, 
but yes.

> ...and implicitly implemented by every value type:

Yes.

> Sup<E> from Collection<any E> could then be expressed as:
>
> public interface <T> Collection<any E extends Any<T>> extends 
> Iterable<E> {
>     boolean contains(T x);

Clever.  This is yet another way to express the dependent type "ref T ? 
Object : T" alluded to in the last mail.  Ultimately, I do think that 
the API problem (and several others) boil down to finding a non-scary 
way to refer to this type (and anything with the word "dependent" in it 
fails the scary test.)




More information about the valhalla-spec-experts mailing list