<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 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);" class="elementToProof ContentPasted0">
Hello all,
<div><br class="ContentPasted0">
</div>
<div class="elementToProof">We've redone the presentation to try to make the motivation & connections more clear. The main points are the following: we lift restrictions around primitive type patterns in nested positions, in top-level positions, around constant
case labels and instanceof. The semantics for <code>instanceof</code> are naturally derived from pattern matching. Now
<code>instanceof</code> can safeguard all permitted casts according to Chapter 5.<br>
</div>
<div class="elementToProof"><br>
</div>
<div class="elementToProof"><span class="ContentPasted0 ContentPasted1" style="margin:0px"><a href="https://openjdk.org/jeps/8288476" id="LPlnk825959">https://openjdk.org/jeps/8288476</a></span><br class="ContentPasted1">
</div>
<div class="elementToProof"><span class="ContentPasted0 ContentPasted1" style="margin:0px"><br>
</span></div>
<div class="ContentPasted0">Let us know of your thoughts. </div>
Angelos<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Brian Goetz <brian.goetz@oracle.com><br>
<b>Sent:</b> 26 January 2023 17:04<br>
<b>To:</b> Guy Steele <guy.steele@oracle.com><br>
<b>Cc:</b> forax@univ-mlv.fr <forax@univ-mlv.fr>; Angelos Bimpoudis <angelos.bimpoudis@oracle.com>; amber-spec-experts <amber-spec-experts@openjdk.org><br>
<b>Subject:</b> Re: Draft JEP on Primitive types in patterns, instanceof, and switch</font>
<div> </div>
</div>
<div><font size="4"><font face="monospace">Yes, pardon my quick typing. <br>
<br>
More specifically, a case constant is not a _constant pattern_ (at least, not yet), it is just a constant case label. Constants are typed, and they carray both a type match and a value match. When you say
<br>
<br>
case 0<br>
<br>
this is a constant for an int, and doesn't match a floating point zero (if the match target is `float`, it won't even compile.) Similarly, `case 0.0` is a constant for a float, and is not applicable to a match target of int. (We do have the usual tolerance
for matching int constants to shorter int types, as before.)<br>
<br>
We may generalize these to constant patterns in the future, but right now, these are constant case labels and their semantics are derived from that of existing case labels.<br>
</font></font><br>
<div class="x_moz-cite-prefix">On 1/26/2023 10:25 AM, Guy Steele wrote:<br>
</div>
<blockquote type="cite"><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jan 26, 2023, at 9:36 AM, Brian Goetz <<a href="mailto:brian.goetz@oracle.com" class="x_moz-txt-link-freetext">brian.goetz@oracle.com</a>> wrote:</div>
<br class="x_Apple-interchange-newline">
<div class="">
<div class=""><font class="" size="4"><font class="" face="monospace">... <br class="">
<br class="">
For comparing a variable to a constant, representational equality is the obvious interpretation; `case nnn` means "is it the number nnn". This allows you to say `case NaN` and `case -0` and get the right answer (all of these relations agree on what to do about
1.0). <br class="">
</font></font></div>
</div>
</blockquote>
<br class="">
</div>
<div>Careful: I think you had better say “<font class="" face="Menlo"><span class="" style="font-style:normal">case -0.0</span></font>”; otherwise the constant expression “<font class="" face="Menlo"><span class="" style="font-style:normal">-0</span></font>”
will be reduced to “<font class="" face="Menlo"><span class="" style="font-style:normal">0</span></font>” and only then converted to floating-point representation, producing
<font class="" face="Menlo"><span class="" style="font-style:normal">+0.0</span></font>.</div>
<div class=""><br class="">
</div>
Yes, floating-point is VERY fiddly.
<div class=""><br class="">
<style class="" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div class="">—Guy</div>
<div class=""><br class="">
</div>
</div>
</blockquote>
<br>
</div>
</body>
</html>