<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <br>
    <div class="moz-cite-prefix">On 3/21/2023 5:39 PM, Holo The Sage
      Wolf wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAKswmE7-K_ei4zFWkkCDwfx1BEdkONtxuxm=L7qS0AafmvSzzQ@mail.gmail.com">
      
      <div dir="ltr">
        <div class="markdown-here-wrapper" style="">
          <p style="margin:0px 0px 1.2em!important">Is there a reason
            not to allow implicit Unnamed Variables in
            try-with-resources and Catch-block?</p>
        </div>
      </div>
    </blockquote>
    <br>
    The JEP already describes these cases:<br>
    <br>
    <h3 id="Unnamed-variables" style="font-size: 10pt; font-weight:
      bold; font-style: italic; padding: 0pt; margin: 1ex 0pt; color:
      rgb(0, 0, 0); font-family: "DejaVu Sans",
      "Bitstream Vera Sans", "Luxi Sans", Verdana,
      Arial, Helvetica; font-variant-ligatures: normal;
      font-variant-caps: normal; letter-spacing: normal; orphans: 2;
      text-align: start; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; text-decoration-thickness:
      initial; text-decoration-style: initial; text-decoration-color:
      initial;">Unnamed variables</h3>
    <p style="padding: 0pt; margin: 1ex 0em; color: rgb(0, 0, 0);
      font-family: "DejaVu Sans", "Bitstream Vera
      Sans", "Luxi Sans", Verdana, Arial, Helvetica;
      font-size: 13.3333px; font-style: normal; font-variant-ligatures:
      normal; font-variant-caps: normal; font-weight: 400;
      letter-spacing: normal; orphans: 2; text-align: start;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      text-decoration-thickness: initial; text-decoration-style:
      initial; text-decoration-color: initial;">The following kinds of
      declarations can introduce either a named variable (denoted by an
      identifier) or an unnamed variable (denoted by an underscore):</p>
    <ul style="margin-top: 1ex; margin-bottom: 1ex; margin-right: 2em;
      padding-left: 2em; list-style-type: square; color: rgb(0, 0, 0);
      font-family: "DejaVu Sans", "Bitstream Vera
      Sans", "Luxi Sans", Verdana, Arial, Helvetica;
      font-size: 13.3333px; font-style: normal; font-variant-ligatures:
      normal; font-variant-caps: normal; font-weight: 400;
      letter-spacing: normal; orphans: 2; text-align: start;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      text-decoration-thickness: initial; text-decoration-style:
      initial; text-decoration-color: initial;">
      <li style="margin-top: 0pt; margin-bottom: 0pt;">A local variable
        declaration statement in a block (JLS 14.4.2),</li>
      <li style="margin-top: 0pt; margin-bottom: 0pt;">A resource
        specification of a<span> </span><code style="font-family:
          "DejaVu Sans Mono", "Bitstream Vera Sans
          Mono", "Luxi Mono", "Courier New",
          monospace;">try</code>-with-resources statement (JLS 14.20.3),</li>
      <li style="margin-top: 0pt; margin-bottom: 0pt;">The header of a
        basic<span> </span><code style="font-family: "DejaVu Sans
          Mono", "Bitstream Vera Sans Mono", "Luxi
          Mono", "Courier New", monospace;">for</code><span> </span>statement
        (JLS 14.14.1),</li>
      <li style="margin-top: 0pt; margin-bottom: 0pt;">The header of an
        enhanced<span> </span><code style="font-family: "DejaVu
          Sans Mono", "Bitstream Vera Sans Mono",
          "Luxi Mono", "Courier New", monospace;">for</code><span> </span>loop
        (JLS 14.14.2),</li>
      <li style="margin-top: 0pt; margin-bottom: 0pt;">An exception
        parameter of a<span> </span><code style="font-family:
          "DejaVu Sans Mono", "Bitstream Vera Sans
          Mono", "Luxi Mono", "Courier New",
          monospace;">catch</code><span> </span>block (JLS 14.20), and</li>
      <li style="margin-top: 0pt; margin-bottom: 0pt;">A formal
        parameter of a lambda expression (JLS 15.27.1).</li>
    </ul>
    <br>
    Try with resources, and catch blocks, are listed as places where you
    can use unnamed variables.  Am I undersatnding your question
    properly?<br>
    <br>
    <br>
    <br>
    <blockquote type="cite" cite="mid:CAKswmE7-K_ei4zFWkkCDwfx1BEdkONtxuxm=L7qS0AafmvSzzQ@mail.gmail.com">
      <div dir="ltr">
        <div class="markdown-here-wrapper" style="">
          <p style="margin:0px 0px 1.2em!important">To allow:</p>
          <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-java" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)">    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">try</span> (Scope.open()) {
        ...
    }
---
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">try</span> { ... }
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">catch</span> (Exception) { ... }
</code></pre>
          <p style="margin:0px 0px 1.2em!important">to be implicitly</p>
          <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-java" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)">    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">try</span> (var _ = Scope.open()) {
        ...
    }
---
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">try</span> { ... }
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">catch</span> (Exception _) { ... }
</code></pre>
          <p style="margin:0px 0px 1.2em!important">Unlike a normal
            expression, and expression on the RHS of a
            try-with-resources variable has an explicit context, there
            is no fear of someone forgetting the result of the
            expression by mistake.</p>
          <p style="margin:0px 0px 1.2em!important">In a Catch block the
            exception is uniquely accessible through the variable
            declared in the declaration of the block, so there is no
            fear that someone will get confused by this implicitness.</p>
          <p style="margin:0px 0px 1.2em!important">This implicitness
            will make stuff like logging context, which is far from a
            niche use case, much more elegant.</p>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, Mar 21, 2023 at
          9:17 PM Mark Reinhold <<a href="mailto:mark.reinhold@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">mark.reinhold@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"><a href="https://openjdk.org/jeps/443" rel="noreferrer" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://openjdk.org/jeps/443</a><br>
          <br>
            Summary: Enhance the Java language with unnamed patterns,
          which match<br>
            a record component without stating the component's name or
          type,<br>
            and unnamed variables, which can be initialized but not
          used. Both<br>
            are denoted by an underscore character, _. This is a preview
          language<br>
            feature.<br>
          <br>
          - Mark</blockquote>
      </div>
      <br clear="all">
      <div><br>
      </div>
      <span class="gmail_signature_prefix">-- </span><br>
      <div dir="ltr" class="gmail_signature">
        <div dir="ltr">Holo The Wise Wolf Of Yoitsu</div>
      </div>
    </blockquote>
    <br>
  </body>
</html>