enhanced type-inference

Brian Goetz brian.goetz at oracle.com
Sun Jan 27 10:32:03 PST 2013

> Very nice, indeed. Congratulations!
> We now hardly need casts if APIs are written correctly.

What do you mean by "correctly"?  Obviously "no overloading at all" 
would help, but that's a pretty big departure from where Java has been. 
  (Some other languages that rely heavily on type inference prohibit 
overloading except on arity, for that reason.)  Do you have other 
practices in mind that will help here?

> One idea that might make the remaining needed casts more concise, but I
> don't know how it would play with this new inference scheme, is a kind
> of "diamond cast".

Yes, this is a promising idea.  We've discussed this internally a number 
of times but it was always a lower priority than other features. 
Similarly, "partial diamond", where you only provide enough information 
to "unstuck" inference, rather than "all or nothing", could make 
explicit type information more compact.  This could help not only with 
diamond or the diamond cast idea, but also with explicit type witnesses.

More information about the lambda-dev mailing list