JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Jan 26 15:08:24 UTC 2018
In response to the many comments in this thread, let me clarify what the
goals are here:
* first, as in JDK 10 we have 'var' in certain places (local variable
decl, for loop variable, try with resource variable), it seems
consistent to apply 'var' in other places too; a lambda parameter is yet
another case where the parameter type is implicitly typed, so it kind of
makes sense to let the programmer be able to use 'var' if he/she so wishes.
* the second reason, which was pointed out correctly in the email, is to
provide a path to add modifiers (such as 'final') and or annotations to
a lambda parameter w/o the need of resorting to explicit types. That is
IMHO a small, but valuable improvement. Also note that, while
availability of annotations on lambdas at runtime depends on the
translation strategy, there could be compile-time clients (e.g.
annotation processors) that might be interested in consuming such
annotations.
* I'm not too worried about the restriction of mixing 'var' and implicit
parameter in the same lambda, because I'd say that mixing var and legacy
implicitly typed param leads to less readable code IMHO. That said,
there's actually no technical reason for enforcing this constraint, so
this might be a point where we might have some degree of freedom (or
which could be revised at a later date).
* There *is* a technical reason behind not allowing a mix of explicit
and implicit parameters, so that's not up for debate. That has been the
case since JDK 8, and it did not create any concern.
Regards
Maurizio
On 25/01/18 19:40, mark.reinhold at oracle.com wrote:
> The following JEP is proposed to target JDK 11:
>
> 323: Local-Variable Syntax for Lambda Parameters
> http://openjdk.java.net/jeps/323
>
> Feedback on this proposal is more than welcome, as are reasoned
> objections. If no such objections are raised by 23:00 UTC on Thursday,
> 1 February, or if they're raised and then satisfactorily answered, then
> per the JEP 2.0 process proposal [1] I'll target this JEP to JDK 11.
>
> - Mark
>
>
> [1] http://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html
More information about the jdk-dev
mailing list