<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">On 18 Oct 2022, at 7:47, Remi Forax wrote:</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #999999; color: #999999;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #BBBBBB; color: #BBBBBB;"><p dir="auto">javac -Xlint:all MyScopedLock.java</p>
</blockquote><p dir="auto">MyScopedLock.java:23: warning: [try] auto-closeable resource ignored is never
<br>
referenced in body of corresponding try statement
<br>
try(MyScopedLock ignored = l.lock()) {
<br>
^
<br>
1 warning</p>
</blockquote><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #999999; color: #999999;"><p dir="auto">So here we may have a clash of philosophies for the enhanced-for and how people
<br>
use the `AutoCloseable`.</p>
</blockquote><p dir="auto">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().</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;">
<p dir="auto">I think the opposite on this one. It seems to me that using <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">_</code> is an excellent way to mute that warning. I find it annoyingly opinionated: Why shouldn’t I expect to use TWR to simulate the RAII-style open/close events from C++, without lint bumping my elbow?</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><p dir="auto">If we allow '_', it means that we are in a way able to call _.close().</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;">
<p dir="auto">The documentation for desugaring TWR can just introduce a new name if necessary; the JLS introduces unnamed temps all the time and this is just another place for one.</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><p dir="auto">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>
So reject
<br>
int x, _;</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;">
<p dir="auto">I agree.</p>
</div></div></body>
</html>