JEP: Derived Record Creation: Another Method
Nathan Reynolds
numeralnathan at gmail.com
Fri Jan 26 16:25:04 UTC 2024
I am looking at JEP Derived Record Creation.
https://openjdk.org/jeps/8321133 I see the following example.
Point nextLoc = oldLoc with {
x *= 2;
y *= 2;
z *= 2;
};
If the body of the wither becomes more complex, then this will make
reading the code difficult. For example, there could be a deep
nesting of wither.
Lambdas can also be nested. However, the best practice is to move
multiline lambda bodies into a separate method and leave behind a
single line that calls the method. The ability to move the lambda
bodies to another method allows for simplification of the code and
improves readability.
Can we change the design to allow withers to be moved to another
method? I ask without thinking through the ramifications. If withers
can't be moved to another method, how do we eliminate nesting and
other complexities?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240126/d881352f/attachment.htm>
More information about the amber-dev
mailing list