lambda expression parameters

Remi Forax forax at univ-mlv.fr
Tue Dec 18 14:57:23 PST 2012


On 12/18/2012 11:40 PM, Sam Pullara wrote:
> I agree with Remi that immutability and final are somewhat orthogonal. However, I am all for making the lambda parameters always final.
>
> Sam

Same answer as Brian, why ?

Brian and you seems to always forget that each time that you consider 
that the lambda semantics is different from the classical method semantics,
you make the whole Java mental model more complex. This kind of changes 
are far from free.

Currently, the way to solve the scope of parameters for lambda and the 
scope of parameter for a method are different,
for no reason in my opinion, at least not good enough reason, and you 
are asking to go a step further.

So I fully agree with your proposal, but instead of just making lambda 
parameters always final,
because it's really that important, why not making all method parameters 
always final.

Rémi
BTW, The primary purpose of a programming language is to get things 
done, without bothering the user and both of you are adding fences and 
traps.

> On Dec 18, 2012, at 2:33 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
>> 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 anyway.
>>
>> 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>
>>
>> Hi
>>
>> 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.
>>
>> Thanks,
>>
>> Venkat
>>
>>
>>



More information about the lambda-spec-experts mailing list