<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"John Rose" <john.r.rose@oracle.com><br><b>To: </b>"Brian Goetz" <brian.goetz@oracle.com><br><b>Cc: </b>"amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Sent: </b>Saturday, September 10, 2022 2:45:16 AM<br><b>Subject: </b>Re: Array patterns (and varargs patterns)<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">I was practicing that trick all morning!</p>
<p dir="auto">I agree that <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">Foo[P]</code> can be saved for later.</p>
<p dir="auto">In case it wasn’t clear in my previous message, I also think that splicey stuff like <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">new Foo[]{ ...as, b, c, ...ds, e }</code> and the corresponding slicey patterns can <em>also</em> be saved for later.</p>
<p dir="auto">In fact, the slice/splice stuff seems like it is best situated in a larger design exercise for “collection literals” whatever those are.  Basically, that would be where Lisp’s backquote-comma get inherited by Java.</p></div></div></blockquote><div><br></div><div>yes,<br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">On 9 Sep 2022, at 17:16, Brian Goetz wrote:</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><p dir="auto">John pulled a nice Jedi-mind-trick on me, and pointed out that we actually have two creation expressions for arrays:</p>
<p dir="auto">    new Foo[n]
<br>
    new Foo[] { a0, .., an }</p>
<p dir="auto">and that if we are dualizing, then we should have these two patterns:</p>
<p dir="auto">    new Foo[] { P0, ..., Pn }  // matches arrays of exactly length N
<br>
    new Foo[P]                 // matches arrays whose length match P</p>
<p dir="auto">but that neither</p>
<p dir="auto">    new Foo[] { P, Q, ... }   // previous suggestion
<br>
nor
<br>
    new Foo[L] { P, Q }       // current suggestion</p>
<p dir="auto">correspond to either of those, which suggests that we may have prematurely optimized the pattern form.  The rational consequence of this observation is to do</p>
<p dir="auto">    new Foo[] { P0, ..., Pn }  // matches arrays of exactly length N</p>
<p dir="auto">now (which is also the basis of varargs patterns), and once we have constant patterns (which are kind of required for the second form to be all that useful), come back for `Foo[P]`.</p>
<br></blockquote></div>
<div class="markdown" style="white-space: normal;">

</div></div><br></blockquote></div></div></body></html>