Accessing non-final local variables from a lambda expression
Rémi Forax
forax at univ-mlv.fr
Mon Mar 1 07:15:30 PST 2010
Le 28/02/2010 22:16, Fredrik Öhrström a écrit :
> Peter Levart wrote:
>
>> With "frame object" I meant an object, allocated on the heap whose class is constructed by
>> compiler and holds all captured local variables (whether final or non-final). I don't know why but
>> this terminology is used by Neal and others.
>>
>> With MethodHandles, local vars can be captured one-by-one via (MethodHandles.insertArgument) but
>> it might still be better to construct a single "frame object" to hold all of them when their
>> number reaches a certain limit or when at least one of them is non-final.
>>
>>
> Be aware that insertArgument might very well be implemented as
> a "closure" using a frame object. See the sample implementation in:
> http://tinyurl.com/q8v92o#InsertArgument
> and the appendArgument implementation at the end of
> http://tinyurl.com/pekyrc
>
> //Fredrik
>
Peter, latest java.dyn API has a method named MethodHandles.insertArguments
(with a 's' at the end) that allow to insert more than one argument.
Rémi
More information about the lambda-dev
mailing list