Towards Minimal L World
Ali Ebrahimi
ali.ebrahimi1781 at gmail.com
Fri May 18 09:58:31 UTC 2018
Hi,
On Fri, May 18, 2018 at 5:03 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> How about this (which is not unlike one of the ideas you proposed earlier
> for pattern declarations):
>
> - For a value type V with fields f1 .. fn, let the user write a
> constructor as if it were a regular class.
> - The compiler inserts synthetic blank finals f`1..f`n, and translates
> accesses to this.fi to accesses to f`i
> - The compiler requires that all f`i are DA at all normal completion
> points, and inserts { default_value / witfield* } copying from the
> synthetic f`i locals
>
> Now, a value ctor looks _exactly_ like a ctor in a non-value type with
> final fields. No new idioms to learn.
>
I don't think quite so, consider this:
public value class Value
{
int x;
int y;
public Value()
{
this.x = 10;
Supplier<Value> f1 = () -> this;
this.y = 15;
Supplier<Value> f2 = () -> this;
assert(f1.get() == f2.get());
}
}
--
Best Regards,
Ali Ebrahimi
More information about the valhalla-spec-observers
mailing list