[fpc-pascal] Syntax changes suggestions
Henry Vermaak
henry.vermaak at gmail.com
Tue Jul 17 11:40:16 CEST 2018
On Tue, Jul 17, 2018 at 11:14:31AM +0200, Michael Van Canneyt wrote:
> On Tue, 17 Jul 2018, Henry Vermaak wrote:
> >On Mon, Jul 16, 2018 at 03:02:42PM +0200, Sven Barth via fpc-pascal wrote:
> >>Santiago A. <svaa at ciberpiula.net> schrieb am Mo., 16. Juli 2018, 13:41:
> >>
> >>> I have some suggestions of change to freepascal syntax, just to debate
> >>>
> >>> (All are backward compatible)
> >>>
> >>> - Declaring variables inside blocks, and loop variables
> >>>
> >>-> reduces readability -> no interest
> >
> >How can it reduce readability? You move variables closer to where they
> >are used, therefore reducing clutter in the main "var" section.
>
> Pascal separates declaration from implementation. This proposal changes
> that, it mixes implementation with declaration.
No, it will still separate the declaration, but just on the block level.
For example:
for i := 0 to n - 1 do
var
foo: integer = 0;
begin
// ...
end;
> When you look for a variable, you know it is in the declaration block.
> If you need to start scanning the code, this is a major nuisance.
If you're in a block, you look at the "var" section of the block first,
then move up a block and repeat. Calling it "a major nuisance" is
needless hyperbole. In the above code, why do I want to see foo in the
main "var" block of the function? It's just noise there, reducing
readability.
> I can't count the misunderstandings in Javascript due to this 'feature'.
This feature makes you properly reduce scope of variables, I seriously
haven't met anyone that thinks this is a bad idea. It's standard
programming practise in every language I've worked.
Henry
More information about the fpc-pascal
mailing list