Project Lambda: Java Language Specification draft
Zdenek Tronicek
tronicek at fit.cvut.cz
Tue Jan 26 23:44:22 PST 2010
Neal Gafter napsal(a):
> On Mon, Jan 25, 2010 at 8:05 AM, Zdenek Tronicek <tronicek at fit.cvut.cz>
> wrote:
>> Right. It is not specified well. However, the correction is not
>> difficult:
>>
>> SAM sam = #()(3);
>>
>> is desugared to
>>
>> SAM sam = new SAM() {
>> public int f() { return 3; }
>> }
>
> That only works when the expression being converted is a lambda. What
> if it is some other expression of function type?
A variable of function type?
#int() p = #()(3);
SAM sam = p;
After desugaring:
final #int() pp = p;
SAM sam = new SAM() {
public int f() { return pp.invoke(); }
}
Or method invocation?
#int() method() { return #()(3); }
SAM sam = method();
After desugaring:
SAM sam = new SAM() {
public int f() { return method().invoke(); }
}
> It also doesn't play well with these parts of the specification:
>
> On Fri, Jan 22, 2010 at 2:55 PM, Alex Buckley <Alex.Buckley at sun.com>
> wrote:
>> It is a goal of this document
>> to allow the implementer freedom as to how and when lambda expressions
>> are evaluated.
Freedom is fine (and you can trust me, I spent a childhood in communist
Czechoslovakia). However, one must ask here: what is the proposed freedom
motivated by? And will not it blur the semantics?
Z.
--
Zdenek Tronicek
FIT CTU in Prague
More information about the lambda-dev
mailing list