Question about Array Patterns

Brian Goetz brian.goetz at oracle.com
Wed Feb 11 15:23:30 UTC 2026


> 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/ef0c9731/attachment.htm>


More information about the amber-dev mailing list