<div dir="ltr">Hi Angelos,<div><br></div><div>The overall direction and writeup for this looks good to me.  I think we need to be more specific about how doubles & floats fit into this though as they are perpetual source of special cases.</div><div><br></div><div>The JEP says:</div><div>> Once instanceof becomes meaningful for primitive types, this provides an obvious interpretation<br>> for primitive type patterns (and reference type patterns as applied to a primitive target):<br>> "could I cast the match target to the type in this pattern without error or loss of precision?"<br><br>This makes sense for most of the primitives we like to think about (int, byte, char, short, long) but may be more complicated for doubles and floats. Conversions to & from float/double are hard to validate that there will be no loss of precision.  if we require exact conversions for them, we'll find that they can only be applied in very narrow cases.  Is that the intention or do we need a more flexible notion of "without error or loss of precision" doubles and floats?<br><br>For example, "JLS 5.1.2 Widening Primitive Conversion" which is one of the valid conversions in a casting context indicates that:<br>      "A widening primitive conversion from int to float, or from long to float, or from long to<br>       double, may result in loss of precision, that is, the result may lose some of the least<br>       significant bits of the value."<br></div><div><br></div><div>It would be good to expand on what the expected behaviour for floats / doubles when used with instanceof.  </div><div><br></div><div>This shouldn't take away from the overall direction of the JEP which I think is the right approach - it's just a corner case we need to clarify.</div><div><br></div><div>--Dan</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 14, 2022 at 6:21 PM Angelos Bimpoudis <<a href="mailto:angelos.bimpoudis@oracle.com">angelos.bimpoudis@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg393395030968444514">




<div dir="ltr">
<div style="font-size:11pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
Dear experts, </div>
<div style="font-size:11pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div><br>
</div>
<div>The draft JEP for adding support for primitive types in
<code>instanceof</code>​ and type patterns, that has been previously discussed on this list, is available at:</div>
<div><br>
</div>
<div><a href="https://bugs.openjdk.org/browse/JDK-8288476" target="_blank">https://bugs.openjdk.org/browse/JDK-8288476</a></div>
<div><br>
</div>
<div>Suggestions are welcomed!</div>
Angelos<br>
</div>
</div>

</div></blockquote></div>