<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;" data-mce-style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;"><div>the previous message was sent too fast, sorry for the inconvenience,<br></div><div><br></div><hr id="zwchr"><div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;"><b>From: </b>"Angelos Bimpoudis" <<span class="Object" role="link" id="OBJ_PREFIX_DWT1772_ZmEmailObjectHandler">angelos.bimpoudis@oracle.com</span>><br><b>To: </b>"amber-spec-experts" <<span class="Object" role="link" id="OBJ_PREFIX_DWT1773_ZmEmailObjectHandler">amber-spec-experts@openjdk.java.net</span>><br><b>Sent: </b><span class="Object" role="link" id="OBJ_PREFIX_DWT1774_com_zimbra_date">Friday, October 14</span>, 2022 4:59:08 PM<br><b>Subject: </b>Re: Draft JEP: Unnamed local variables and patterns<br></blockquote></div><div><br></div><div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; 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: #000000;" class="elementToProof ContentPasted0" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;">Hello experts!</div><div style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;" class="elementToProof ContentPasted0" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;"><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>Does the code make no sense or can it be written in a better way ?<br></div><div><br></div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; 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: #000000;" class="elementToProof ContentPasted0" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;"><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></div><div> for(boolean unused = sideEffects(); ...;) { ... }<br></div><div>i think that replacing "unused" by '_' is a step forward.</div><div><br></div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; 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: #000000;" class="elementToProof ContentPasted0" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;"><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"><span class="Object" role="link" id="OBJ_PREFIX_DWT1775_com_zimbra_date">Today</span> 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 the variable is used to call close() so i think it is a good idea to maintain the idea that a try-with-resources is just a syntactic sugar on top of a try/finally that call close().<br></div><div>If we allow '_', it means that we are in a way able to call _.close().<br data-mce-bogus="1"></div><div><br></div><div>The other case is the case (2), should we allow '_' in a middle of an init list, i think that like with 'var' we should not allow '_' in an init list.<br data-mce-bogus="1"></div><div>So reject<br data-mce-bogus="1"></div><div> int x, _;<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: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; 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: #000000;" class="elementToProof ContentPasted0" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;"><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</div></blockquote><div><br></div><div>regards,<br data-mce-bogus="1"></div><div>RĂ©mi<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: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: helvetica, arial, sans-serif; font-size: 12pt;"><hr style="display: inline-block; width: 98%;" data-mce-style="display: inline-block; width: 98%;"><div id="divRplyFwdMsg" dir="ltr"><span style="font-size: 11pt; color: #000000; font-family: Calibri, sans-serif;" data-mce-style="font-size: 11pt; color: #000000; font-family: Calibri, sans-serif;"><b>From:</b> amber-spec-experts <<span class="Object" role="link" id="OBJ_PREFIX_DWT1776_ZmEmailObjectHandler">amber-spec-experts-retn@openjdk.org</span>> on behalf of Angelos Bimpoudis <<span class="Object" role="link" id="OBJ_PREFIX_DWT1777_ZmEmailObjectHandler">angelos.bimpoudis@oracle.com</span>><br><b>Sent:</b><span class="Object" role="link" id="OBJ_PREFIX_DWT1778_com_zimbra_date">29 September 2022</span> 19:03<br><b>To:</b> amber-spec-experts <<span class="Object" role="link" id="OBJ_PREFIX_DWT1779_ZmEmailObjectHandler">amber-spec-experts@openjdk.java.net</span>><br><b>Subject:</b> Draft JEP: Unnamed local variables and patterns</span><div> </div></div><div dir="ltr"><div class="x_elementToProof x_ContentPasted0" style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;" data-mce-style="font-family: 'segoe ui', 'segoe ui ', 'helvetica neue', sans-serif; font-size: 11pt; color: #000000;">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"><span class="Object" role="link" id="OBJ_PREFIX_DWT1780_com_zimbra_url"><a target="_blank" href="https://bugs.openjdk.org/browse/JDK-8294349" rel="noopener" data-mce-href="https://bugs.openjdk.org/browse/JDK-8294349">https://bugs.openjdk.org/browse/JDK-8294349</a></span><br data-mce-bogus="1"></div><div><br class="x_ContentPasted0"></div><div class="x_ContentPasted0">Comments welcomed!</div>Angelos<br></div></div><br></blockquote></div></div></div></div></div></body></html>