<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <blockquote type="cite" cite="mid:CAG7BDeZ6B0p1Cmy48PhzAxL1AhsfDxLqnnGJhw4-GF9xdwAd2Q@mail.gmail.com">
      
      <div dir="ltr">
        <p style="line-height:100%;margin-bottom:0cm">
          In thinking about record destructuring it occurs to me it
          could be
          used in more places than currently proposed.</p>
      </div>
    </blockquote>
    <br>
    Yes, these are what we've been calling "imperative destructuring",
    where an exhaustive pattern can be used in a non-conditional
    context.  There was a hint of this in the experimental use of record
    patterns in foreach loops, we've talked about a `let` or `match`
    statement a fair bit, and have briefly discussed using destructuring
    in method headers (though we are pretty negative on that one right
    now.)  <br>
    <br>
    We're being deliberately conservative about this; right now it feels
    like it's in the "because we can" stage, and that's where mistakes
    come from.  We will revisit when we nail down the declaration story
    for matchers, since these are likely to come back into play when we
    address matcher implementations delegating to other matchers
    (analogous to "super" calls in constructors.)  <br>
    <br>
    <blockquote type="cite" cite="mid:CAG7BDeZ6B0p1Cmy48PhzAxL1AhsfDxLqnnGJhw4-GF9xdwAd2Q@mail.gmail.com">
      <div dir="ltr">
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">One example would
          be
          in a function call:</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">record
          HumanName(firstName: String, middleName: String, lastName:
          String) {}</p>
        <p style="line-height:100%;margin-bottom:0cm">HumanName
          humanName
          = new HumanName(“Alice”, “Bateman”, “Chandler”);</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">String
          getFormattedName(humanName: HumanName(firstName, _, lastName))</p>
        <p style="line-height:100%;margin-bottom:0cm">{</p>
        <p style="line-height:100%;margin-bottom:0cm">   return lastName
          +
          “, “ + firstName;</p>
        <p style="line-height:100%;margin-bottom:0cm">}</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">final String
          fmtName
          = getFormattedName(humanName);</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">another could be
          in
          a for loop</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">final
          Set<HumanName>
          humans = new HashSet<>();</p>
        <p style="line-height:100%;margin-bottom:0cm">humans.add(humanName);</p>
        <p style="line-height:100%;margin-bottom:0cm">for (final
          humanName: HumanName(firstName, _, lastName): humans)</p>
        <p style="line-height:100%;margin-bottom:0cm">{</p>
        <p style="line-height:100%;margin-bottom:0cm">  
          processFirstName(firstName);</p>
        <p style="line-height:100%;margin-bottom:0cm">  
          processLastName(lastName);</p>
        <p style="line-height:100%;margin-bottom:0cm">   ...</p>
        <p style="line-height:100%;margin-bottom:0cm">}</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">or indeed in any
          body</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
        <p style="line-height:100%;margin-bottom:0cm">with humanName as
          HumanName(firstName, _, lastName)</p>
        <p style="line-height:100%;margin-bottom:0cm">{</p>
        <p style="line-height:100%;margin-bottom:0cm">  
          processFirstName(firstName);</p>
        <p style="line-height:100%;margin-bottom:0cm">  
          processLastName(lastName);</p>
        <p style="line-height:100%;margin-bottom:0cm">   ...</p>
        <p style="line-height:100%;margin-bottom:0cm">}</p>
        <p style="line-height:100%;margin-bottom:0cm"><br>
        </p>
      </div>
    </blockquote>
    <br>
  </body>
</html>