On May 17, 2018, at 11:07 AM, Maurizio Cimadamore <[email protected]> wrote: > > While I think going down into a syntactic bikeshed right now would be way too > premature, IMHO, one thing that the language has to figure out is how the > construction model for value types is exposed to programmers. Withers are > very good at the bytecode level, not so much at the source level. Whatever we > can do to minimize the entry barrier there I think would be very welcome.
I think our starting point is porting classic Java constructor syntax & semantics to the value world. This gives programmers a way (which is awkward but workable) to build withers etc. 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. An explicit wither can simply reconstruct another instance from scratch. This is a workaround in place of direct access to a single wither instruction, using a special syntax. (…Which has been previously discussed in terms like v2=__With(v.x, y) or something similar.) As a workaround, classic Java constructors are good enough to allow other experiments to get off the ground. After all, they are good enough for VBCs. — John P.S. Teaser: Generalizing classic Java constructors to cover the case of withers and ad hoc update instructions is the subject of a forthcoming-but-delayed memo concerning "reconstructors".
