Options for accessing local variables

Artur Biesiadowski abies at adres.pl
Sun Mar 21 00:03:28 PDT 2010


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