capturing (or not) mutable local variables
Jesse Sightler
jesse.sightler at gmail.com
Sat Nov 20 17:28:00 PST 2010
As an average Java developer, I don't think so. It's just like anonymous
inner classes, except with more easily permitted mutable state.
The stuff about multithreaded accumulators is a major red herring IMO.
On Nov 20, 2010 4:25 PM, "Brian Goetz" <brian.goetz at oracle.com> wrote:
> Surely you realize (a) would be a huge departure from the experience
> of typical java developers. Who do not read the jls.
>
> Sent from my iPhone
>
> On Nov 20, 2010, at 4:08 PM, Neal Gafter <neal at gafter.com> wrote:
>
>> On Sat, Nov 20, 2010 at 1:29 AM, Brian Goetz
>> <brian.goetz at oracle.com> wrote:
>> If you want to capture a not-effectively-final local variable in a
>> closure, then one of the following two things has to happen:
>> a) The lifetime of the variable must be extended to the lifetime of
>> the closure
>> b) The lifetime of the closure must be shortened to the lifetime of
>> the variable.
>>
>> The JLS doesn't talk about the lifetime of local variables because,
>> like all variables and dynamically allocated objects, they simply
>> cease to exist when they can no longer be referenced. There would
>> be no need to change that.
>>
>
More information about the lambda-dev
mailing list