<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div data-marker="__QUOTED_TEXT__"><div>[...]<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;"><blockquote cite="mid:1724934379.19079517.1659732755546.JavaMail.zimbra@u-pem.fr"><blockquote><pre class="moz-quote-pre"></pre>
      </blockquote>
      <pre class="moz-quote-pre">"provide new bindings" => do you have an example of that ?</pre>
    </blockquote>
    <p><br>
    </p>
    <p>Sure:</p>
    <p><span style="font-family:monospace"><span style="color:#000000;background-color:#ffffff;">public class
          TA {
        </span><br>
           public static void main(String... args) {
        <br>
               Object o = new Box("");
        <br>
               switch (o) {
        <br>
                   case Box b when b.o() instanceof String s ->
        System.err.println(s);
        <br>
                   default -> {}
        <br>
               }
        <br>
           }
        <br>
           record Box(Object o) {}
        <br>
        }<br><br><br></span></p>
    <p>(There can be any number of new bindings from the guard, of
      course.)</p>
    <p><br>
    </p>
    <blockquote cite="mid:1724934379.19079517.1659732755546.JavaMail.zimbra@u-pem.fr">
      <pre class="moz-quote-pre">I don't think a guard should be allowed to do that. It looks like a big gunfoot to me.</pre>
    </blockquote>
    <p><br>
    </p>
    <p>I believe the current specification supports guards that
      introduce new bindings:</p>
    <p><a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~gbierman/jep427%2b405/jep427+405-20220601/specs/patterns-switch-record-patterns-jls.html#jls-6.3.4" target="_blank">http://cr.openjdk.java.net/~gbierman/jep427%2b405/jep427+405-20220601/specs/patterns-switch-record-patterns-jls.html#jls-6.3.4</a><br data-mce-bogus="1"></p>
    <p><br>
    </p>
    <p>To me, it seems desirable. In any case, an implementation PR is
      probably not very well suited to discuss opinions on what should
      be specced. In particular (but not only) a PR that is not expected
      to change the semantics.</p></blockquote><div><br></div><div>Ok, thanks for the example, it means we should lift the when expression not has a static method but as a static pattern method, something which will be more clear when we will have a better idea about how to do that once user defined pattern method like Optional.of(value -> ...) will be introduced.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>RĂ©mi<br data-mce-bogus="1"></div><div><br></div></div></div></body></html>