Project Lambda: Java Language Specification draft

Zdenek Tronicek tronicek at fit.cvut.cz
Wed Jan 27 23:22:59 PST 2010


Neal Gafter napsal(a):
> On Wed, Jan 27, 2010 at 12:47 PM, Zdenek Tronicek <tronicek at fit.cvut.cz>
> wrote:
>> Of course, this is a perfect motivation. But, for me, it is so natural
>> as
>> if the compiler extract assignment to x out of the loop:
>>
>> int x;
>> for (int i = 0; i < 10; i++) {
>>  x = 42;
>>  System.out.println(i);
>> }
>>
>> The desugaring I mentioned should viewed as description of semantics.
>> Not
>> prescription to the compiler.
>
> Because the identity of the resulting objects is observable, such an
> optimization is not correct unless the identity is not specified.
>

I am not sure if I understand you. Does the following solve the identity
problem?

> It is a goal of this document
> to allow the implementer freedom as to how and when lambda expressions
> are evaluated.

No. (Or is this an attempt to say that the identity is not defined?) So,
you must define the identity in either case. And once you define it, any
optimization that follows given rules should be legal.

Z.
-- 
Zdenek Tronicek
FIT CTU in Prague



More information about the lambda-dev mailing list