Lambda syntax puzzler

Sam Pullara spullara at gmail.com
Thu Oct 17 03:10:34 PDT 2013


I’m ok with this. It is trivial to do the transformation from an inner class that mutates its parameters to a lambda that doesn’t. 

I still would like the variable name scoping to change though at this late date I don’t expect that to happen. It is very common in the Scala code bases I have seen to reuse the outside name as the inside name, now there will be some ugly convention that adds a number or a _ or something.

Sam

On Oct 16, 2013, at 7:05 AM, Remi Forax <forax at univ-mlv.fr> wrote:

> On 10/16/2013 03:43 PM, Millies, Sebastian wrote:
>> Yes, I like that proposal as well. Only thing could suffer would be automatic conversion
>> of inner classes to lambdas, if those class implementations mutated their parameters.
>> That would not concern me. -- Sebastian
> 
> I think that the main issue I see, is that there is no Java keyword for 
> saying 'not final',
> so if by example you have a method that calls a lambda with the bounds
> of a partition of an array, you can not write a code like this:
> (array, i, end) -> {
>  for(; i < end; i++) {
>    ... array[i] ...
>  }
> }
> 
> With the proposal of Stuart, you need to introduce a new local variable
> (array, start, end) -> {
>  for(int i = start; i < end; i++) {
>    ... array[i] ...
>  }
> }
> 
> That's said, it's not a big issue
> 
> cheers,
> Rémi
> 
>> 
>> -----Original Message-----
>> From: lambda-dev-bounces at openjdk.java.net [mailto:lambda-dev-bounces at openjdk.java.net] On Behalf Of Zhong Yu
>> Sent: Wednesday, October 16, 2013 2:31 PM
>> To: Stuart Marks
>> Cc: lambda-dev at openjdk.java.net
>> Subject: Re: Lambda syntax puzzler
>> 
>> On Tue, Oct 15, 2013 at 1:34 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
>>> Either that, or make lambda formal parameters implicitly final. I've
>>> always
>> That is apparently a good idea with no objections; how come EG isn't adopting it? what are the concerns?
>> 
>>> hated code that mutated its parameters anyway.
>>> 
>>> s'marks
>>> 
>>> On 10/12/13 6:50 AM, Samir Talwar wrote:
>>>> :-D
>>>> 
>>>> Now that traditional C-style `for` loops are a thing of the past, I
>>>> think we should expunge the increment and decrement operators from the language.
>>>> Python had the right idea.
>>>> 
>>>> — Samir.
>>>> 
>>>> 
>>>> On Sat, Oct 12, 2013 at 1:27 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>>>> 
>>>>> I'm sure that people of this list will be able to see the beauty of
>>>>> the following code produced by one of my students.
>>>>>    IntPredicate p = i -> i --> 0;
>>>>> 
>>>>> Rémi
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>> 
>> Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
>> 
>> 
> 
> 



More information about the lambda-dev mailing list