Options for accessing local variables
Stephen Colebourne
scolebourne at joda.org
Mon Mar 22 05:05:05 PDT 2010
I´m on holiday, so the original email and this one were v. quick.
If someone wants to takle the original and fix or extend I´d be happy .
Stephen
On 21 March 2010 04:03, Artur Biesiadowski <abies at adres.pl> wrote:
> Hello
>
> One more missing -
>
> Variables are copied on construction AND final inside lambda. They can
> be modified afterwards in calling scope.
>
> int[] total = new int[1];
> Utils.each(list, #(String str) { total[0] += str.length() });
>
> I think it would be nice to extend the examples with modification of
> total in calling scope - it is not always clear if variables has to be
> effectively final or not.
>
> Regards,
> Artur Biesiadowski
>
>
> Neal Gafter wrote:
>> You failed to list the choices made in CfJ, the draft specification, and the
>> strawman:
>>
>> CfJ) Full access to local variables, but a warning if a variable is accessed
>> when not annotated and not effectively final.
>> Draft) Access to local variables only if effectively final.
>> Strawman) Full access to local variables if effectively final or a keyword
>> appears on the variable declaration.
>>
>> Cheers,
>> Neal
>>
>> On Sat, Mar 20, 2010 at 5:05 AM, Stephen Colebourne <scolebourne at joda.org>wrote:
>>
> [...]
>
>
More information about the lambda-dev
mailing list