Could JEP 468 support a single expression?
Stephen Colebourne
scolebourne at joda.org
Fri Mar 1 09:14:20 UTC 2024
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
More information about the amber-dev
mailing list