<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>"Angelos Bimpoudis" <angelos.bimpoudis@oracle.com><br><b>To: </b>"amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Sent: </b>Friday, October 14, 2022 4:59:08 PM<br><b>Subject: </b>Re: Draft JEP: Unnamed local variables and patterns<br></blockquote></div><div><style style="display:none;"> P {margin-top:0;margin-bottom:0;} </style></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: "Segoe UI", "Segoe UI ", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Hello experts!</div>
<div style="font-family: "Segoe UI", "Segoe UI ", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Regarding the code locations where underscore is being introduced: The EG</div>
<div class="ContentPasted0">already agreed on local variables and lambda parameters only, for now. To recap,</div>
<div class="ContentPasted0">this approach has the advantage of mostly lining up with the uses of `var` and</div>
<div class="ContentPasted0">also, that it includes code locations that deal with implementation details, as</div>
<div class="ContentPasted0">opposed to API (fields or method formal parameters). Thus, the N places where</div>
<div class="ContentPasted0">locals are declared in Java are the following:</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">1. the header of an enhanced for loop </div>
<div class="ContentPasted0">2. a local variable declaration statement in a block </div>
<div class="ContentPasted0">3. a catch formal parameter</div>
<div class="ContentPasted0">4. a formal parameter of a lambda expression</div>
<div class="ContentPasted0">5. a pattern variable</div>
<div class="ContentPasted0">6. the header of a basic for statement</div>
<div class="ContentPasted0">7. a resource specification of a try-with-resources statement</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">The obvious place to start introducing the meaning of the underscore token is to</div>
<div class="ContentPasted0">"all of these", targeting uniformity in the language. The downside is that some</div>
<div class="ContentPasted0">of those places are pretty messy (e.g., for loops) and Java developers may not</div>
<div class="ContentPasted0">like this.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">So, this puts us in a position between two general principles: uniformity</div>
<div class="ContentPasted0">(support all of the above) and being seen to have introduced underscore in</div>
<div class="ContentPasted0">places where underscore shouldn't make sense. </div></div></blockquote><div><br></div><div>Should not make sense or can be written in a better way ?<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: "Segoe UI", "Segoe UI ", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Where things are getting confusing are the following:</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">6. the header of a basic for statement</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">At the moment, there is code out there that uses the for statement in weird</div>
<div class="ContentPasted0">ways, like:</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">`for(sideEffects(), moreSideEffects(); condition() > flag;) { }`</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">This is admittedly already a bit confusing. Do we really want to add to that the</div>
<div class="ContentPasted0">ability to use underscore?</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">`for (var _ = sideEffects(); true; ) { ... }`</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">That code could be refactored to:</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">```</div>
<div class="ContentPasted0">var _ = sideEffects();</div>
<div class="ContentPasted0">for (; true; ) { ... }</div>
<div class="ContentPasted0">```</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">I am wondering if `_` has a place in the init list of a regular for..</div></div></blockquote><div><br></div><div>Given that people already write things like<br data-mce-bogus="1"></div><div> for(boolean unused = sideEffects(); ...;) { ... }<br data-mce-bogus="1"></div><div>i think that replacing "unused" by '_' is a step forward. </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: "Segoe UI", "Segoe UI ", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">7. a resource specification of a try-with-resources statement</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Today we get this warning with a TWR-statement if the local is ignored:</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">> javac -Xlint:all MyScopedLock.java</div>
<div class="ContentPasted0">MyScopedLock.java:23: warning: [try] auto-closeable resource ignored is never referenced in body of corresponding try statement</div>
<div class="ContentPasted0"> try(MyScopedLock ignored = l.lock()) {</div>
<div class="ContentPasted0"> ^</div>
<div class="ContentPasted0">1 warning</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">So here we may have a clash of philosophies for the enhanced-for and how people</div>
<div class="ContentPasted0">use the `AutoCloseable`.</div></div></blockquote><div><br></div><div>I think we should disallow '_' here, mostly because <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: "Segoe UI", "Segoe UI ", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Looking forward to hearing your thoughts.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Best,</div>
Angelos<br>
</div>
<hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> amber-spec-experts <amber-spec-experts-retn@openjdk.org> on behalf of Angelos Bimpoudis <angelos.bimpoudis@oracle.com><br><b>Sent:</b> 29 September 2022 19:03<br><b>To:</b> amber-spec-experts <amber-spec-experts@openjdk.java.net><br><b>Subject:</b> Draft JEP: Unnamed local variables and patterns</font>
<div> </div>
</div>
<style style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_elementToProof x_ContentPasted0" style="font-family:"Segoe UI","Segoe UI ","Helvetica Neue",sans-serif; font-size:11pt; color:rgb(0,0,0)">
Dear experts,
<div><br class="x_ContentPasted0">
</div>
<div class="x_ContentPasted0">The draft JEP for unnamed local variables and patterns, that has been previously discussed on this list is available at:</div>
<div><br class="x_ContentPasted0">
</div>
<div class="x_ContentPasted0">https://bugs.openjdk.org/browse/JDK-8294349</div>
<div><br class="x_ContentPasted0">
</div>
<div class="x_ContentPasted0">Comments welcomed!</div>
Angelos<br>
</div>
</div><br></blockquote></div></div></body></html>