Towards Minimal L World

Maurizio Cimadamore maurizio.cimadamore at
Thu May 17 23:40:01 UTC 2018

On 17/05/18 23:22, John Rose wrote:
> A Java constructor in a value class will internally use withfield
> to translate any assignment of the form "this.x = y", and instead
> of the blank instance being an incoming reference in L[0], the
> constructor builds a blank value instances out of thin air using
> vdefault.
So, if I understand correctly, a classic Java constructor is a 
void-returning instance method; in the model you propose a value class 
constructor would be more similar to a V-returning static method (where 
V is the value to be constructed).

This is all and well, but I feel that this pushes the problem under the 
(assignment) rug. E.g. I believe that reinterpreting the meaning of 
'this.x = y' inside a value constructor to mean "get a brand new value 
and stick y into x" would be very confusing, as semantically, there's no 
assignment taking place. And, semantically, it doesn't even make sense 
to think about a 'this' (after all this is more like a static factory?).

Of course you can spin this as reinterpreting the meaning of the word 
'this' inside a value constructor - e.g. the new meaning being "the 
opaque value being constructed"; but that is likely to clash with other 
utterances of 'this' in the same value class (e.g. in other instance 
methods - where 'this' would simply mean 'this value').

Language-wise (and I repeat, it might well be too soon to dive into 
this), it feels like we're missing a way to express a new kind of a 
primitive operation (the wither). Without that, I'm a bit skeptical on 
our ability to be able to express value type constructors in a good way.


More information about the valhalla-spec-observers mailing list