Question about Array Patterns
David Alayachew
davidalayachew at gmail.com
Wed Feb 11 17:06:21 UTC 2026
Understood, and agreed that this discussion should be shelved for now. I'll
save any follow up questions for if/when a jep or doc for this comes out.
Ty vm for the context. Excited for the future of pattern matching!
On Wed, Feb 11, 2026, 10:23 AM Brian Goetz <brian.goetz at oracle.com> wrote:
>
> I guess I just don't see how a prefix match would be considered an
> unpacking and not a query. What makes a prefix match an unpacking while a
> suffix match is a query? I'm not seeing that detail yet. But I do see why a
> center match is a query. That is unquestionably so.
>
>
> Think about it it comparison to
>
> p instanceof Point(var x, _)
>
> You are logically unpacking x and y, but you don't care about y.
> Similarly, with a "there could be more but I don't care" on an array, you
> are unpacking the first N, and don't care about the rest.
>
> There are alternate ways to structure it (matching on the length instead
> of the body, which would admit a constant pattern) but that's a detail.
>
> In any case, we are well afield here; this particular feature is "on the
> shelf" for now.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20260211/38f88430/attachment.htm>
More information about the amber-dev
mailing list