Accessing non-final local variables from a lambda expression

Peter Levart peter.levart at gmail.com
Sun Feb 28 12:19:53 PST 2010


Oh, I haven't got that far. And there's nothing in a method that could render it unsafe 
considering the criteria I suggested (only capture of non-final local vars by lambda). But I 
guess if you wanted to extend @Safe tracking to methods (and consequently to method references) 
compiler would use the same logic as for lambda bodies and attach a 'synthetic' annotation to a 
method if it determines that it is @Safe. The type of a Method reference would then inherit this 
annotation from the method the reference refers to.

Peter

On Sunday 28 February 2010 08:57:32 pm Paulo Levi wrote:
> Besides would that catch the case when a pure function is turned into a
> "impure" function?
> 
> Say
> 
> @Pure public int add(int x){
> return 2+x;
> }
> ....
> parallelMap(list, #add(int i));
> 
> 
> later in refactoring:
> @Pure public c = 2;
> public int add(int x){
> return c+x;
> }
> Can annotations hijack the type system to this level?


More information about the lambda-dev mailing list