<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof ContentPasted1" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Updated draft spec. </div>
<div class="elementToProof ContentPasted1" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof ContentPasted1" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Includes a small number of fixes and a correct "rebase" on top of the JLS changes resulting from JEP 432 (Record Patterns (Second Preview)) and JEP 433 (Pattern Matching for switch (Fourth Preview)) that covers Maurizio's point.</div>
<div class="elementToProof" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<a href="https://cr.openjdk.org/~abimpoudis/unnamed/latest/" data-auth="NotApplicable" id="LPlnk416801">https://cr.openjdk.org/~abimpoudis/unnamed/latest/</a><br>
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
(please note that the based URL has been slightly changed ^^)</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span class="ContentPasted0 ContentPasted2" style="margin:0px">Comments are always very much welcomed!</span><span style="background-color:rgb(255,255,255); display:inline!important"></span><br class="Apple-interchange-newline ContentPasted2">
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Best,</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Angelos</div>
<div class="elementToProof ContentPasted0" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div id="appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Angelos Bimpoudis <angelos.bimpoudis@oracle.com><br>
<b>Sent:</b> 24 February 2023 17:23<br>
<b>To:</b> Maurizio Cimadamore <maurizio.cimadamore@oracle.com>; Brian Goetz <brian.goetz@oracle.com>; amber-spec-experts <amber-spec-experts@openjdk.java.net><br>
<b>Subject:</b> Re: Draft JLS Spec about unnamed patterns and variables</font>
<div> </div>
</div>
<div dir="ltr">
<div class="x_elementToProof" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="x_elementToProof" style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
The main takeaways:</div>
<div style="font-family:"Segoe UI","Segoe UI Web (West European)","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<ul>
<li class="x_elementToProof x_ContentPasted0 x_ContentPasted1 x_ContentPasted2">case Number _ can fall out to other patterns since it doesn't introduce any bindings (adjustment in the spec draft is needed)<br>
</li><li class="x_elementToProof x_ContentPasted0 x_ContentPasted1">case Number _ dominates case String
<span style="background-color:rgb(255,255,255); display:inline!important">_</span>, Integer
<span style="background-color:rgb(255,255,255); display:inline!important">_ (adjustment is not needed in current draft, but I will double check before I circulate the revised version).</span><br>
</li></ul>
<div class="x_elementToProof"><span style="background-color:rgb(255,255,255); display:inline!important"></span></div>
<span style="font-size:11pt; margin:0px; background-color:rgb(255,255,255)">Thanks for all the comments!</span><br>
<span style="font-size:11pt; margin:0px; background-color:rgb(255,255,255)"></span>
<div><span style="background-color:rgb(255,255,255); display:inline!important">
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-left:3px solid rgb(200,200,200); border-top-color:rgb(200,200,200); border-right-color:rgb(200,200,200); border-bottom-color:rgb(200,200,200); padding-left:1ex; margin-left:0.8ex; color:rgb(102,102,102)">
Thought experiment: what if we had union type patterns? Then the case label `case String _, Integer _` would be like matching the the union type pattern `(String|Integer) _`:
<div><br class="x_ContentPasted3">
</div>
<div class="x_ContentPasted3"> case Number n: ...</div>
<div class="x_ContentPasted3"> case (String|Integer) _: ...</div>
<div><br class="x_ContentPasted3">
</div>
<div class="x_ContentPasted3">Would javac then complain that `String|Integer` could be simplified to just `String` on the bsais of flow analysis? (IntelliJ would, of course.)
</div>
<div><br class="x_ContentPasted3">
</div>
<div>I initially thought as Tagir did, but then Gavin turned me around and reminded me that it was not dead code, but unreachable statements that we try to avoid. So now I am torn...<br>
</div>
</blockquote>
<div class="x_elementToProof x_ContentPasted5 x_ContentPasted6">Would union type patterns imply the existence of union types? If yes, then, the second case could even exist with a binding, correct? In your example the LUB is Object so even the case (String|Integer)
x : x.getClass() can work. The difficult scenario would arise with the <span class="x_ContentPasted7" style="background-color:rgb(255,255,255); display:inline!important">case (Customer|Human) x : x.getName();</span></div>
<div class="x_elementToProof"><br>
</div>
<div class="x_elementToProof x_ContentPasted8">If the first case in your example did not introduce a binding, would both case be equal with Number | (String | Integer)? Union types a la Ceylon support this (<a href="http://web.mit.edu/ceylon_v1.3.3/ceylon-1.3.3/doc/en/spec/html_single/#uniontypes" data-auth="NotApplicable" id="LPlnk473936">http://web.mit.edu/ceylon_v1.3.3/ceylon-1.3.3/doc/en/spec/html_single/#uniontypes</a>).
On the other hand in Ceylon, the switch needs to be exhaustive <b>and</b> all cases need to be disjoint. So this switch would be invalid. hm..</div>
<div class="x_elementToProof"><br>
</div>
</span></div>
</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Maurizio Cimadamore <maurizio.cimadamore@oracle.com><br>
<b>Sent:</b> 23 February 2023 20:27<br>
<b>To:</b> Brian Goetz <brian.goetz@oracle.com>; Angelos Bimpoudis <angelos.bimpoudis@oracle.com>; amber-spec-experts <amber-spec-experts@openjdk.java.net><br>
<b>Subject:</b> Re: Draft JLS Spec about unnamed patterns and variables</font>
<div> </div>
</div>
<div>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
<div class="x_x_moz-cite-prefix">On 23/02/2023 18:46, Brian Goetz wrote:<br>
</div>
<blockquote type="cite"><font size="4"><font face="monospace">but we really wanted the case merging.</font></font></blockquote>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<font size="4"><font face="monospace">Gotcha.</font></font></p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<font size="4"><font face="monospace">I just wanted to point out that there are two questions here (one about fall-through and one about domination), and when reading the emails it was not obvious to me that a change in how fall-through was defined was being
proposed.</font></font></p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<font size="4"><font face="monospace">If merging unrelated type tests is a goal, I think there should be an example for it in the JEP under "Motivation".</font></font></p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<font size="4"><font face="monospace">Maurizio<br>
</font></font></p>
</div>
</div>
</body>
</html>