[fpc-pascal] Syntax changes suggestions
Santiago A.
svaa at ciberpiula.net
Mon Jul 16 16:46:58 CEST 2018
El 16/07/2018 a las 13:59, Michael Van Canneyt escribió:
>
>
> 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;
It is a local variable to the block, the scope is the from the
declaration to the end of the block. Nevertheless, I think that
declarations should be at the beginning of the block, before any
executable statement, so the scope is the block.
Ada, has the structure
-------------
if a>b then
Declare
s:string='aaaa';
begin
<...>
end;
end if;
--------------
I just say that the nearer the variable to the place you use it, the
better. Particularly in the case of FOR loops it makes a lot of sense.
In fact, the variable shouldn't make sense before or after the loop. Why
not declare it just in the loop? Ada does it.
I don't think Ada is a language of dirty hacks.
--
Saludos
Santiago A.
More information about the fpc-pascal
mailing list