I saw that Primitive Types in Patterns is being withdrawn from the JDK 28 preview. Why remove it now, and what happens to the idea of switching on a boolean?
Why is Java dropping primitive patterns in JDK 28?
Answers
The sticking point is exact numeric conversion. Valhalla is exploring a broader model for Java numerics, potentially including user-defined numeric types. Those types would need to fit into the conversion rules too, and that work is still evolving.
Finalizing primitive patterns with today's definition could lock in rules that don't fit the eventual design. The preview is being removed from JDK 28 rather than finalized in its current form.
Reply to this answer
The boolean switch was appealing as a kind of if expression, especially when each branch needs a block of code before producing a value. Losing the preview means that particular approach won't be available in JDK 28.
For now, an ordinary if statement or a small method can do the job. Neither is quite the same expression syntax, though.
Reply to this answer
There's also a bigger design question around how custom numeric types might participate in these operations. Some people are hoping for something like type classes, but there isn't a type class proposal to preview here, and the witness-type ideas being discussed have their critics too.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Nuvrali.4x:
That seems like a reasonable tradeoff. A preview is a better place to change course than a feature Java has to support indefinitely.