<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>I have some suggestions of change to freepascal syntax, just to
      debate<br>
    </p>
    <p>(All are backward compatible)</p>
    <p>- Declaring variables inside blocks, and loop variables<br>
      - Autofree pointers<br>
      - Try except finally blocks<br>
      - Private declarations in implementation<br>
      <br>
      some of them can be found in
<a class="moz-txt-link-freetext" href="https://www.codeproject.com/Articles/1252167/Delphi-Language-Progression-Suggestions">https://www.codeproject.com/Articles/1252167/Delphi-Language-Progression-Suggestions</a><br>
      <br>
      <b>*declaring variables inside blocks, and loop variables*</b><br>
    </p>
    <tt><tt><tt>var</tt><tt><br>
        </tt><tt> Number1,number2:Integer;</tt><tt><br>
        </tt><tt> f:textFile;</tt><tt><br>
        </tt><tt>begin</tt><tt><br>
        </tt><tt>  <...></tt><tt><br>
        </tt><tt>  while not eof(f) do begin</tt><tt><br>
        </tt><tt>     Readln(f,number1,number2);</tt><tt><br>
        </tt><tt>     if number1>number2 then </tt><tt><br>
        </tt><tt>       begin</tt><tt><br>
        </tt><tt>         var swapnum:Integer;</tt><tt> // declaring in
          a block. Even initializing it,  </tt></tt></tt><tt><tt><tt><tt><tt><tt>var
                swapnum:Integer:=Number1;</tt></tt></tt><br>
        </tt><tt>         swapnum:=number1;</tt><tt><br>
        </tt><tt>         number1:=number2;</tt><tt><br>
        </tt><tt>         number2:=swapnum;</tt><tt><br>
        </tt><tt>       end;        </tt><tt><br>
        </tt><tt>  end;</tt><tt><br>
        </tt><tt>  <...></tt><tt><br>
        </tt><tt>end;   </tt><br>
        <br>
        ---------------<br>
        <br>
      </tt>for var i:integer:=1 to 100 do </tt><tt><br>
    </tt><tt>   begin</tt><tt><br>
    </tt><tt>      <...></tt><tt><br>
    </tt><tt>   end;<br>
      <br>
    </tt><tt>---------------<br>
      <br>
    </tt><b>*autofree pointers*</b><br>
    <br>
    <tt>procedure foo;</tt><tt><br>
    </tt><tt>  var s:TStringList; auto;</tt><tt> // you add "auto", like
      absolute<br>
    </tt><tt>begin</tt><tt><br>
    </tt><tt>  s:=TStringList.create;</tt><tt><br>
    </tt><tt>  <..></tt><tt><br>
    </tt><tt>  // s is freed automatically</tt><tt> at the end of block,
      without try finally<br>
    </tt><tt>end;</tt><tt><br>
    </tt><br>
    That combined with declaring inside blocks would make things less
    verbose avoiding a lot of try finally.<br>
    <br>
    <b>*try except finally blocks*</b><br>
    <br>
    instead of<br>
    <br>
    <tt>------------------<br>
       try</tt><tt><br>
    </tt><tt>    try</tt><tt><br>
    </tt><tt>      <...></tt><tt><br>
    </tt><tt>    except</tt><tt><br>
    </tt><tt>       <...></tt><tt><br>
    </tt><tt>    end;</tt><tt><br>
    </tt><tt> finally</tt><tt><br>
    </tt><tt>    <...></tt><tt><br>
    </tt><tt> end;</tt><tt><br>
    </tt><tt>------------------<br>
    </tt>  <br>
    just write<br>
     <br>
    <tt><tt>------------------</tt><br>
       try</tt><tt><br>
    </tt><tt>    <...></tt><tt><br>
    </tt><tt> except</tt><tt><br>
    </tt><tt>    <...></tt><tt><br>
    </tt><tt> finally</tt><tt><br>
    </tt><tt>    <...></tt><tt><br>
    </tt><tt> end;</tt><tt><br>
    </tt> <br>
    <b>*Private declarations in implementation*</b><br>
    <br>
    In the implementation, being able to implement a private method
    without declaring it in the interface part. <br>
    You just write:<br>
    <br>
    <tt>-------------------------<br>
      implementation</tt><tt><br>
    </tt><tt><br>
    </tt><tt>procedure TMyClass.MyPrivateMethod;</tt><tt><br>
    </tt><tt>begin</tt><tt><br>
    </tt><tt>  <...></tt><tt><br>
    </tt><tt>end;</tt><tt><br>
      -------------------------<br>
    </tt><br>
    And if it is not declared in the interface part, it is assumed as
    private.<br>
    It is a private method, nobody is aware of it outside of the
    implementation, it can't be used in derived classes, it unnecessary
    in the interface, and needn't to be declared.<br>
    <br>
    The same could be applied for private vars. :<br>
    <br>
    <tt>--------------------------<br>
      implementation</tt><tt><br>
    </tt><tt><br>
    </tt><tt>var</tt><tt><br>
    </tt><tt> TMyClass.privateVar: Integer;</tt><tt><br>
      --------------------------<br>
    </tt> <br>
    I suppose this is more difficult with variables than with methods,
    because of reserving memory etc, but it would be handy.<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Saludos

Santiago A.
</pre>
  </body>
</html>