Reified Lambda Functions
Maurizio Cimadamore
Maurizio.Cimadamore at Sun.COM
Thu Jan 7 04:11:04 PST 2010
Howard Lovatt wrote:
> I have posted a *more* formal proposal for reifying lambdas (as suggested by
> Neal Gafter):
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=278567
>
> This could be read in conjunction with the original informal proposal:
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=277879
>
> Which is an easier read :)
>
> -- Howard.
>
> 2010/1/3 Neal Gafter <neal at gafter.com>
>
>
Hi Howard
Wouldn't be more elegant to re-use one of the many existing approach to
tackle reification and then restrict it so that only function types are
reified?
The classloader solution you are proposing is very similar to the
solution proposed by the author of NextGen[1] (a reified Java compiler)
- there are some disadvantages with that approach:
1) Creates one classfile per generic instantiation - since you are using
a modified classloader you can probably avoid generating a classfile and
synthesize it on the fly - nevertheless the solution will result in
increased static footprint.
2) Heterogeneous (one class per instantiation, as in C++) approaches for
handling reification have proven to be relatively weak when it comes to
deal with generic methods - this might not be a problem since your goal
is to reify lambdas only which corresponds to classes.
A bunch of additional problems that I see in your approach:
- your proposal does not fully reify lamdas; #(x:List<Integer>) and
#(x:List<String>) will still be identical types
- you need to take into account type-variables; #(x:T) - reification in
this case is much more complex as the concrete type of T will depend on
the generic instantiation of the context in which the lambda is defined.
[1] - http://www.cs.rice.edu/~javaplt/nextgen/
Maurizio
>> On Sun, Jan 3, 2010 at 3:04 PM, Howard Lovatt <howard.lovatt at iee.org>wrote:
>>
>>
>>> I have updated the post to cover your example; thanks it is another
>>> difficult case that needs to be addressed. The updated blog is at
>>>
>>> http://www.artima.com/forums/flat.jsp?forum=106&thread=277879&start=0&msRange=15
>>> .
>>> I have included a list example like the one you gave. For comparing
>>> lambda's
>>> you need to use equals not ==.
>>>
>>> Keep the difficult cases coming there may be more subtile bugs in the
>>> proposal that these examples will tease out.
>>>
>>>
>> It isn't clear how to generalize your particular examples into rules for
>> handling all examples. While the examples are helpful, they don't really
>> provide much confidence in the concepts without those underlying rules. Can
>> you please try to formulate your proposal into a set of more generic rules
>> for handling all cases? Trying to formalize the rules would also help us
>> (and you) to understand if and where rules might be missing.
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the MessageLabs Email Security System.
>> For more information please visit http://www.messagelabs.com/email
>> ______________________________________________________________________
>>
>>
>
>
>
>
More information about the lambda-dev
mailing list