Equality

Brian Goetz brian.goetz at oracle.com
Sat Dec 19 22:20:48 UTC 2015


> 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.

Yes.  That's totally valid (any is a modifier for a type variable 
declaration, whether introduced at the class or method level.)  Its 
worth noting that there's some degree of extra dispatch cost for generic 
instance methods (a separate topic, but something to keep in mind) which 
is a slight negative for going generic on such a critical method as 
equals().  But yes, that's valid.

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

OK, we're on the same page.  I think we're coming at the "superate" 
concept from different directions, but both roads lead there.


More information about the valhalla-spec-experts mailing list