<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Am 28.05.2022 um 14:04 schrieb Benito
      van der Zander via fpc-pascal:<br>
    </div>
    <blockquote type="cite"
      cite="mid:836a6507-0487-c3cb-3f0b-dc9ff25ac05e@benibela.de">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div id="smartTemplate4-template">Hi, <br>
      </div>
      <div><br>
      </div>
      <div>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">Sort((left, right) begin
                    if left < right then
                      result := -1
                    else if left > right then
                      result := 1
                    else
                      result := 0;
                  end);
</pre>
        </blockquote>
        <br>
        <div>One could introduce the @ operator to get a reference to a
          block of code.<br>
        </div>
        <div>
          <p> </p>
          <blockquote type="cite"> </blockquote>
          <pre class="moz-quote-pre" wrap="">Sort( @(left, right) begin
                    if left < right then
                      result := -1
                    else if left > right then
                      result := 1
                    else
                      result := 0;
                  end);</pre>
        </div>
      </div>
    </blockquote>
    <br>
    The sequence "@(identifier" is already a valid sequence (because
    "@(SomeVar)" is valid) and I'm definitely and absolutely against
    introducing another ambigous syntax as I already have enough
    headaches with Delphi's generic syntax.<br>
    <br>
    <blockquote type="cite"
      cite="mid:836a6507-0487-c3cb-3f0b-dc9ff25ac05e@benibela.de">
      <div>
        <div>
          <pre class="moz-quote-pre" wrap="">
</pre>
        </div>
      </div>
      <div><br>
      </div>
      <div>The "result" variable is also ugly. You could make "if" an
        expression:<br>
      </div>
      <div><br>
      </div>
      <div>
        <pre class="moz-quote-pre" wrap="">Sort( @(left, right) begin
                    result :=  
                      if left < right then -1
                      else if left > right then 1
                      else 0;
                  end);</pre>
      </div>
    </blockquote>
    <br>
    Allowing if (and case) to be an expression, too, is something I'm
    still toying with independantly of this...<br>
    <br>
    <blockquote type="cite"
      cite="mid:836a6507-0487-c3cb-3f0b-dc9ff25ac05e@benibela.de">
      <div>
        <pre class="moz-quote-pre" wrap="">
</pre>
        <div><br>
        </div>
        Then the begin end could be removed too. Make @:= an operator to
        turn an expression to a function</div>
      <br>
      <div>
        <pre class="moz-quote-pre" wrap="">Sort( @(left, right) := 
                       if left < right then -1
                       else if left > right then 1
                       else 0;
                  );
</pre>
        <div><br>
        </div>
      </div>
    </blockquote>
    <br>
    I personally would have a bit more verbose syntax though it would
    have the same problem regarding type inference which would be an
    absolute PITA to implement (not to mention the opposition from the
    other core devs):<br>
    <br>
    === code begin ===<br>
    <br>
    Sort(lamba (left, right) as<br>
      if left < right then -1<br>
      else if left > right then 1<br>
      else 0);<br>
    <br>
    === code end ===<br>
    <br>
    Regards,<br>
    Sven<br>
  </body>
</html>