Could JEP 468 support a single expression?

Brian Goetz brian.goetz at oracle.com
Fri Mar 1 14:28:24 UTC 2024


Yes, considerable consideration has been given to this.  It turns out it 
is trickier than it looks, but we understand that it is desirable, and 
will try to make it happen if we can.

On 3/1/2024 4:14 AM, Stephen Colebourne wrote:
> I believe that many, if not most, uses of derived record creation
> expressions will have a single assignment. Has consideration been
> given to allowing a single assignment expression instead of a block?
>
> eg this:
>    record Complex(double re, double im) {
>      Complex conjugate() { return this with { im = -im; }; }
>      Complex realOnly()  { return this with { im = 0; }; }
>      Complex imOnly()    { return this with { re = 0; }; }
>    }
>
> becomes:
>    record Complex(double re, double im) {
>      Complex conjugate() { return this with im = -im; }
>      Complex realOnly()  { return this with im = 0; }
>      Complex imOnly()    { return this with re = 0; }
>    }
>
> In general, I think this JEP is OK, but it doesn't move the needle
> much without a mechanism to create the record in a similar way.
>
> Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240301/6fa70420/attachment.htm>


More information about the amber-dev mailing list