[fpc-pascal] Syntax changes suggestions

Michael Van Canneyt michael at freepascal.org
Mon Jul 16 13:59:15 CEST 2018



On Mon, 16 Jul 2018, Santiago A. wrote:

> I have some suggestions of change to freepascal syntax, just to debate
>
> (All are backward compatible)
>
> - Declaring variables inside blocks, and loop variables
> - Autofree pointers
> - Try except finally blocks
> - Private declarations in implementation
>
> some of them can be found in 
> https://www.codeproject.com/Articles/1252167/Delphi-Language-Progression-Suggestions

Some can be considered regressions, not progression.

autofree pointers will be available with management operators, I suppose.
probably try except finally blocks is still doable.

But declaring variables inside code blocks makes for really bad readability 
and - worse - possibly error prone code.

What to do with scope rules ?

Var
   C : integer;

begin
   C:=1; // C is integer
   // New block, hence new scope
   for var c:string in List do begin
     ... // C is string
   end;

Which is IMO error prone.

the alternative is the javascript way, elevate the "c" in the for loop to a
procedure local variable, in which case the above should result in an error,
and which is a major source of problems.

Either way, I don't think this is very desirable.

Michael.



More information about the fpc-pascal mailing list