<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <font size="4"><font face="monospace">(cross-posting to -comments is
        discouraged)<br>
        <br>
        If we are reconstructing something as trivial as a Point, we
        might not even use a reconstruction expression, since an
        ordinary constructor invocation is probably good enough (it only
        has two components, and we're changing at least one of them.)  <br>
        <br>
        Now imagine you are reconstructing something with a dozen
        components, which is where reconstruction expressions offer more
        value.  I don't think people would be very happy with a syntax
        like<br>
        <br>
            thingie with Thingie(var a, var b, var c, var d, var e, <br>
                                 var f, var g, var h, var i, var j) { a
        = 3 }<br>
        <br>
        <br>
      </font></font><br>
    <div class="moz-cite-prefix">On 10/18/2023 8:01 PM, David Alayachew
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAA9v-_OMrqnnHx5=Zaw4Y_yxPKE5VvvVnm=m5ALsBNVR0shHow@mail.gmail.com">
      
      <div dir="ltr">
        <div class="gmail_default" style="font-family:monospace">Also
          adding <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:amber-dev@openjdk.org" tabindex="-1" moz-do-not-send="true">@amber-dev</a> <br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Oct 18, 2023 at
          8:00 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" moz-do-not-send="true" class="moz-txt-link-freetext">davidalayachew@gmail.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">
          <div dir="ltr">
            <div class="gmail_default" style="font-family:monospace">Adding
              -comments<br>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Sat, Sep 23, 2023 at
              10:54 AM Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">attila.kelemen85@gmail.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">
              <div dir="ltr">Note: I think you would have a better
                chance, if you sent the email to "amber-spec-comments"
                than "observers", since the people who can actually make
                changes are more likely to read the "comments" list.
                <div><br>
                </div>
                <div>That said, I don't really see the usefulness of
                  such a syntax (and adding new syntax in itself is a
                  detriment). That is, if I understood you correctly,
                  then your example would replace this:</div>
                <div><br>
                </div>
                <div>```</div>
                <div>Point p = ...;<br>
                  Point pp = new Point(p.x() + 2, 0);<br>
                </div>
                <div>```</div>
                <div><br>
                </div>
                <div>which is shorter and a lot more obvious. And if we
                  were to go to more complicated things (many
                  properties), then it doesn't help that much, because
                  as far as I understand you, your proposal is still
                  positional in its deconstruction pattern, and the
                  positional nature is usually what is awkward in
                  structures with many properties.</div>
                <div><br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">Harrison Chikwe <<a href="mailto:nhcdeveloper@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">nhcdeveloper@gmail.com</a>>
                  ezt írta (időpont: 2023. szept. 23., Szo, 12:01):<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px
                  0px 0.8ex;border-left:1px solid
                  rgb(204,204,204);padding-left:1ex">
                  <div dir="ltr">
                    <div>Hi,</div>
                    <div><br>
                    </div>
                    <div>I think that it is very useful to have when
                      working with immutable objects.</div>
                    <br>
                    For the purposes of this mail, let's call the design
                    described in the ambro-doc[1]:<br>
                    reconstruction expression with implicit
                    deconstructor (aka REWID).<br>
                    <br>
                    Has it been considered to make the deconstructor
                    pattern explicit in the reconstruction<br>
                    expression (aka REWED)?<br>
                    Doing so may remove the requirement to make names
                    more significant in the language.<br>
                    <br>
                    For example, given the following:<br>
                    <br>
                    Point p = ...;<br>
                    Point pp = p with(int x, int y) { x += 2; y = 0; }<br>
                    <br>
                    We can interpret the reconstruction expression above
                    as:<br>
                    <br>
                    . Find a deconstructor and constructor pair that has
                    a signature that matches (int, int)<br>
                    . Deconstruct the target with the deconstructor<br>
                    . Execute the block on RHS<br>
                    . Invoke the constructor with the result.<br>
                    <br>
                    If we split the reconstruction expression into three
                    steps:<br>
                    <br>
                    1. Extraction<br>
                    2. Transformation<br>
                    3. Construction<br>
                    <br>
                    In REWID users are required only to do step 2
                    (transformation) and the<br>
                    system handles 1 and 3. Whereas in REWED users are
                    required to do step 1 and 2<br>
                    and the system handles just step 3.<br>
                    <br>
                    # Other forms of REWED<br>
                    <br>
                    1. Explicit Named deconstructor pattern<br>
                       <br>
                       Point pp = p with Point(int x, int y) {...}<br>
                    <br>
                    2. Explicit Var deconstructor pattern<br>
                    <br>
                       Point pp = p with var(int x, int y) {...}<br>
                    <br>
                    3. Explicit Unnamed deconstructor pattern<br>
                       <br>
                       Point pp = p with(int x, int y) {...}<br>
                    <br>
                    <br>
                    We can extend form 1 to include factory pattern:<br>
                    <br>
                       Point pp = p with Point.factory(int x, int y)
                    {...}<br>
                    <br>
                    <br>
                    # Advantages<br>
                    <br>
                    1. No need to make names significant.<br>
                    2. Can be combined with other patterns (e.g. unnamed
                    pattern, var pattern)<br>
                    <br>
                       Point pp = p with(int x, _) { x = 0; }<br>
                    <br>
                    <br>
                    Nyehamene.</div>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>