<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>"Brian Goetz" <brian.goetz@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"Gavin Bierman" <gavin.bierman@oracle.com>, "amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Sent: </b>Monday, October 24, 2022 3:17:39 AM<br><b>Subject: </b>Re: Draft Spec for Fourth Preview of Pattern Matching for Switch (JEP 433) and Second Preview of Record Patterns (JEP 432) now available<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;"><br>
    <blockquote cite="mid:2118717224.31682166.1666475526444.JavaMail.zimbra@u-pem.fr">
      <div style="font-family: arial, helvetica, sans-serif; font-size:
        12pt; color: #000000">
        <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;"><font size="4"><font face="monospace">What exactly do you mean
                by this?</font></font></blockquote>
          <div><br>
          </div>
          <div>If i modify a record by adding a new component, i want to
            compiler to help me to find all the switches that are using
            that record so i can re-evaulate if the new component play a
            role or not for each of those codes.</div>
        </div>
      </div>
    </blockquote>
    <br>
    What you're asking for is cool, but enormous, because it involves
    introducing a new dimension into the programming model -- time. 
    Currently, we identify which modifications are binary- or source-
    compatible, and let people make their choices, but the ways in which
    a program has evolved over time is external to the programming
    model.</blockquote><div><br></div><div>The relation to time is not something directly written in the spec but Java has a long tradition of offering tools to deal with the maintenance of libraries and applications.</div><div><br data-mce-bogus="1"></div><div>I'm not proposing to do more, but like we support the use cases related to of maintaining APIs through time i believe we should also support the use cases related to maintaining data through time.<br data-mce-bogus="1"></div><div>And obviously, because those are use cases supported by the language not more, people will be free to program that way or not.<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;">  <br>
    <br>
    Adding a component (and doing nothing else) is technically neither a
    binary- nor source-compatible change.  (Existing constructor
    invocations will fail to link.)  Of course, you can add  a
    constructor overload for the old description -- and soon enough,
    you'll be able to add a deconstructor overload too.</blockquote><div><br></div><div>That's why Java provides reflection or bytecode transformation or annotation processors, which are used to decouple de data description from the data implementation.<br data-mce-bogus="1"></div><div>As an example, frameworks like Spring, Quarkus, Micronaut or Helidon, all provide a way to map JSON objects to records in a loosely coupled way allowing a kind of backward compatibility.<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;">  <br>
    <br>
    <blockquote cite="mid:2118717224.31682166.1666475526444.JavaMail.zimbra@u-pem.fr">
      <div style="font-family: arial, helvetica, sans-serif; font-size:
        12pt; color: #000000">
        <div>
          <div>Then for each code, i can say, i do not care about that
            new component by adding an any pattern or i care about it,
            add a binding and change/fix the code using that binding.<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    The plan for dealing with this is the same as with the constructor:
    write a deconstructor for the old description.  Then all the
    existing match sites will continue to work, and you can use "find
    usages" to decide which ones you want to migrate.  </blockquote><div><br></div><div>In the case of APIs, we want source/binary backward compatibility, but may not necessarily want the same in case of data, because data may not cross boundaries.<br data-mce-bogus="1"></div><div>Using the same example of modern Java frameworks, all those frameworks already define boundaries for the user, how to define a REST API is already defined, how to interact with a database is already defined, etc, so as a user you are already inside an application with well defined boundaries. In that case, you do not care too much about data backward compatibility but more about having the data correctly describing the business and how to update those data when the business requirements change.<br></div><div><br data-mce-bogus="1"></div><div>I'm not proposing to change the language model to introduce the notion of time but to be able to support use cases where the data evolve through time. In my mind, i call that approach "data first".<br data-mce-bogus="1"></div><div>We already have features that goes in that direction, sealed types + switch exhaustiveness is a great way to help users to find what code should be upgraded when a new kind of data need to be added.</div><div><br data-mce-bogus="1"></div><div>RĂ©mi<br></div><div><br data-mce-bogus="1"></div></div></div></body></html>