<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 21, 2024 at 10:30 AM <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</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><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><br></div><div><br></div><hr id="m_-3164441915959647155zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"daniel smith" <<a href="mailto:daniel.smith@oracle.com" target="_blank">daniel.smith@oracle.com</a>><br><b>To: </b>"Remi Forax" <<a href="mailto:forax@univ-mlv.fr" target="_blank">forax@univ-mlv.fr</a>><br><b>Cc: </b>"valhalla-spec-experts" <<a href="mailto:valhalla-spec-experts@openjdk.java.net" target="_blank">valhalla-spec-experts@openjdk.java.net</a>><br><b>Sent: </b>Tuesday, May 21, 2024 4:49:30 PM<br><b>Subject: </b>Re: It starts with a bang ends with a quote<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt">
<div>
<blockquote>
<div>On May 21, 2024, at 1:09 AM, Remi Forax <<a href="mailto:forax@univ-mlv.fr" target="_blank">forax@univ-mlv.fr</a>> wrote:</div>
<br>
<div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Hello,</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">I
 recently tried to convince myself that using a type annotation (the bang '!') was the best way to do type specialization at langage level but I still find it awkward.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">There
 are several reasons why using a bang to ask for type specialization does not work well with the rest of the design of value types.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
</div>
</blockquote>
</div>
<br>
<div>We've considered lots of different variations on specialization, so to be clear: you're critiquing an approach in which Foo<Val!> is specialized, while Foo<String> and Foo<Val> are not. Is that right?</div></blockquote><div><br></div><div>Not exactly, I think we do not need Foo<Val!> at all.<br></div><div><br></div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt">
<div><br>
</div>
<div>I think we're going to end up with a stronger requirement: that Foo<Val!> and Foo<Val> must *both* be specialized. (My inclination has always been to throw Foo<String> in there, too, but that one is more negotiable.)</div>
<div><br>
</div>
<div>Why specialize Foo<Val>? Because we can often still flatten the storage (we're including some flattening of nullable value class types in JEP 401), and in any case we should always scalarize specialized method signatures for value class types.</div></blockquote><div><br></div><div>I will go a step further, by example, in most case an immutable list rejects null, so a list created with ImmutableList via List<Val>.of() should be specialized, it's up to the implementation of ImmutableList to decide which kind of storage to use. So it's not something a user should control, thus no List<Val!>, List<Val> is enough. An for the scalarization, i hope that Val + requireNonNull is enough (we can speculate of the fact that a value type is non null).<br></div><div><br></div><div>Rémi</div></div></div></div></blockquote><div><br></div><div>I'm concerned that eliminating ! also eliminates a lot of benefits. There is a lot of value in ! other than flattening optimizations: Self-documentation, static analysis and (potentially) JVM-enforced runtime non-nullability guarantees. If there is no T! then List.of() cannot have the static return type List<T!>, which it should.<br></div><div><br></div><div>I want the ability to refine any type (not just value types) to exclude nulls. Flattening value type instances is a JVM performance feature, and is not the same as the language feature of non-nullability refinement. I don't see there being another way to get the performance feature as a justification for dropping the language feature.</div><div><br></div><div>Cheers,</div><div>Clement Cherlin<br></div></div></div>