On 21/05/2025 18:06, Paul Sandoz wrote:
It was a design choice to be consistent with each json value having an
X, accepting X in on construction and producing X out (notionally) on
deconstruction, which leans into pattern matching. Definitely pros/cons
to that e.g., we could instead make JonObject implement Map, or do as
you suggest [*], both of which adjust how one reasons about the X in and
X out.
I agree with this. When I wrote, I thought that it might be possible to
address some of these use cases using instance pattern declaration on
the array class (e.g. having an instance pattern that extracts the i-th
element of a JSONArray) -- but the instance pattern proposals we have
discussed so far [1] are not powerful enough to model that use case.
Maurizio
[1] -
https://openjdk.org/projects/amber/design-notes/patterns/towards-member-patterns