Fwd: lambda expression parameters
brian.goetz at oracle.com
Tue Dec 18 14:33:59 PST 2012
I like this suggestion that Venkat made on lambda-dev. However, it
would have to be a little more restrictive than that; basically, that
lambda parameters are *always* final. The only thing where I can
imagine this being an issue is in refactoring from inner classes, and
even there, if you are modifying method parameters, it is likely that
you need to do additional work to adapt this inner class to a lambda
So the suggestion is: lambda formals are always final.
What do people think?
-------- Original Message --------
Subject: lambda expression parameters
Date: Tue, 18 Dec 2012 14:40:25 -0700
From: Venkat Subramaniam <venkats at agiledeveloper.com>
To: lambda-dev at openjdk.java.net <lambda-dev at openjdk.java.net>
Is there plans to make the inferred parameter of a lambda expression
final by default.
Right now, we can't specify the parameter is final unless we provide it
with the type.
In the spirit of leaning towards immutability, which is a better
practice, would it be possible to
(a) make all inferred parameters of lambda expressions final, and
(b) to make it non-final, force the developers to explicitly request
(like the mutable in F#).
It's more of a wish-list, if that's something that can be considered.
More information about the lambda-spec-observers