void handling in expression lambdas and lambda conversion

Neal Gafter neal at gafter.com
Wed Jan 13 14:18:13 PST 2010

On Wed, Jan 13, 2010 at 1:45 PM, Peter Levart <peter.levart at gmail.com> wrote:
> I think it is a good fit. Invocation of a "void" method is a "void"
> expression. Invocation of a #void() function is also a "void" expression. So
> if this is a valid expression statement:
> voidMethod();
> Why should this be not:
> (#() voidMethod()) ();
> (Tennent's principle for expressions?)

You took a (expression) statement and extracted it from its statement
context.  I therefore don't think anything like TCP applies.

>> > I know that "Method References" are even a more compact syntax, but as
>> > specified, are not powerfull enough for specifying this:
>> >
>> > int a = 1;
>> > #void(int) lambda = #(int b) method(a, b);
>> True, but you could write this, which is arguably more clear:
>> #void(int) lambda = #(int b) { method(a, b); }
> It is clear, but the intention is different. The intention of:
> #void(int) lambda = #(int b) { method(a, b); }
> is to construct a nothing-returning lambda regardless of what the method
> returns. The intention of:
> #void(int) lambda = #(int b) method(a, b);
> is to construct a lambda that has the same or at least assignment
> compatible return type as the method.

In any particular context in the source, the method's return type is
either void or not.  So I don't see any hardship in treating them

More information about the closures-dev mailing list