Lambda Concise method and void return type
Tagir Valeev
amaembo at gmail.com
Sun Sep 30 14:30:21 UTC 2018
Hello!
I don't think that `void foo() -> null` should be supported. Like in
lambdas if the method returns void, only expressions which can be used as
expression statement should be allowed. I don't think that special support
for empty bodies is necessary as {} is short enough. Especially if your
code style is not very bureaucratic and allows you to write `void foo() {}`
in single line.
With best regards,
Tagir Valeev.
вс, 30 сент. 2018 г., 20:48 Remi Forax <forax at univ-mlv.fr>:
> Testing the prototype, i've seen myself using -> null instead of a
> classical empty method body when i want to have a method that does nothing.
>
> class A {
> void f() -> null;
> // versus
> void f() {
> }
> }
>
> the compiler translates the concise version to aconst_null pop return
> instead of a plain return.
>
> Obviously, in the real world, people doesn't write empty methods all the
> time and i'm not sure if it's that important, anyway i think that question
> should be raised, should we want to support this a pattern ?
>
> Rémi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20180930/0fc921c2/attachment.html>
More information about the amber-spec-experts
mailing list