Lambda syntax puzzler
Remi Forax
forax at univ-mlv.fr
Wed Oct 16 07:05:50 PDT 2013
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