<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><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;"><b>From: </b>"jan lahoda" <jan.lahoda@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"Jan Lahoda" <jlahoda@openjdk.org>, "Brian Goetz" <brian.goetz@oracle.com>, "compiler-dev" <compiler-dev@openjdk.org><br><b>Sent: </b>Sunday, August 7, 2022 11:22:28 AM<br><b>Subject: </b>Re: [External] : Re: RFR: 8291769: Translation of switch with record patterns could be improved<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><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;"><p>On 07. 08. 22 10:19, <a class="moz-txt-link-abbreviated" href="mailto:forax@univ-mlv.fr" target="_blank">forax@univ-mlv.fr</a> wrote:<br>
    </p>
    <blockquote cite="mid:787533739.19552932.1659860345551.JavaMail.zimbra@u-pem.fr">
      
      <div style="font-family: arial, helvetica, sans-serif; font-size:
        12pt; color: #000000">
        <div>
          <div>[...]<br>
          </div>
          <div><br>
          </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> </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>
            </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>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>Which I guess leaves as with a question: what are we going to do
      until user patterns are defined. Do we keep the current slow code,
      or do we try to improve that (which is that this PR is trying to
      do)? (And maybe learn something in the process.)</p></blockquote><div><br></div><div>I'm ok with this PR but in the long term i hope we can make a better job.</div><div>I still fear people re-organizing their patterns to get more performance instead of getting good performance out of the box.<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;"><p><br>
    </p>
    <p><br>
    </p>
    <p>Jan</p>
    </blockquote><div><br></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:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><p>
    </p>
    <blockquote cite="mid:787533739.19552932.1659860345551.JavaMail.zimbra@u-pem.fr">
      <div style="font-family: arial, helvetica, sans-serif; font-size:
        12pt; color: #000000">
        <div>
          <div><br>
          </div>
          <div>Rémi<br>
          </div>
          <div><br>
          </div>
        </div>
      </div>
    </blockquote><br></blockquote></div></div></body></html>