3 ms·
While to my knowledge there is not yet a final decision, ‘withers’ are planned to solve that. https://github.com/openjdk/amber-docs/blob/master/eg-drafts/recons
by kaba0 5y ago
While to my knowledge there is not yet a final decision, ‘withers’ are planned to solve that. https://github.com/openjdk/amber-docs/blob/master/eg-drafts/reconstruction-records-and-classes.md https://github.com/openjdk/amber-docs/blob/master/eg-drafts/...
Basically, p = p with { .x = 3 } or something like that. But that will also planned to work for other kind of classes and will be a basis for advanced pattern matching as well.
Also, in case of a primitive class with no guarantee of non-tearing, in practice you will get the same performance as with a mutable struct, maybe even better as the JVM can better reason about it.