Unit type?

John Rose john.r.rose at oracle.com
Fri Sep 13 18:55:38 PDT 2013

On Sep 13, 2013, at 6:19 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> public class Void
>    /** a constant for (Void)null */
>    public static final Void VOID = (Void)null;

I like that; it's as concise and better typed than "return null".  How many occurrences of null in the JDK could be be replaced by VOID, today?

>> The workaround is pretty simple:  Continue to worry about "void" as a special case, and put in "return null" when the compiler forces you to.  To me the sad part will be when I have to wrap a lambda body (x,y)->{f(x,y);return null;} around a member reference in order to insert the "return null" into the otherwise reasonable this::f.
> The workaround at this time is to declare "Void f()" instead of "void
> f()". Maybe we should do that extensively for all new methods. And
> maybe we can even do that for all existing "void" methods with
> breaking anything.

That workaround, and Howard's Action0, sounds to me like living with both yards and meters.  :-(

— John

More information about the lambda-dev mailing list