Comments on JDK-8198408 please ?

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Feb 27 10:16:21 UTC 2018



On 27/02/18 01:13, John Rose wrote:
> On Feb 26, 2018, at 4:50 PM, Maurizio Cimadamore 
> <maurizio.cimadamore at oracle.com 
> <mailto:maurizio.cimadamore at oracle.com>> wrote:
>>
>>>>
>>>> I think for now it's better to start simple - only one level 
>>>> allowed and no complex expressions in the selector allowed.
>>>
>>> I don't think there is really a technical reason for this; but of 
>>> course is there is one,
>>> make it simpler by restricting the construct.
>> I agree there's no technical reason to have the restriction - and I 
>> did not propose the restriction because of that - I was only putting 
>> that restriction forward to allow for a 'staged' prototype - e.g. we 
>> can start simple, and add more complex forms as we go, and as we see fit.
>>
>> And no - I did not want an implicit write-back - if user wants 
>> writeback it should do that explicitly:
>>
>> A a = _WithField(a.x, 11);
>
> Got it!  Although I think you didn't mean to make a declaration only?
>
> A a = …;
> a = __WithField(a.x, 11);
Sorry, that was just a bad example on my part. In a normal reference 
world my example doesn't even make sense (as 'a' would be uninitialized 
at that point), but in the value world it could make sense (since values 
are always initialized to the default value). Anyway, your example (with 
separate decl and reassignment is what I had in mind).

Maurizio


>
> — John
>
> P.S. And if we get reconstructor expressions, then such expressions
> would sugar up to something very vaguely like and yet unlike:
>
> b = a __Recon-> x = 10;  // a unchanged, b gets new version of a
> a = a __Recon-> x = 11;  // a gets new version of itself
> a __Recon->= x = 11;  // same as prev
> a = a __Recon-> x++;  // now a.x = 12
> a = a __Recon-> { x = 13; unlucky = true; log("shark jumped"); };
>
> (The reconstructor bodies set fields in exactly the same sense that
> constructors set blank final fields, except that reconstructors also
> provide the previous values of those fields in the previous version
> of the receiver.  If it is further aligned with constructor bodies, it
> can call methods ont the current object, like "log" above.)
>



More information about the valhalla-dev mailing list