[fpc-pascal] Syntax changes suggestions

Michael Van Canneyt michael at freepascal.org
Tue Jul 17 12:07:10 CEST 2018



On Tue, 17 Jul 2018, Henry Vermaak wrote:

> 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.

You are still mixing code with declarations.

>> 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.

I like hyperbole, one can never have too much 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.

Of course not, that's where it belongs.

>> 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.

If you need to "reduce the scope of variables", your routines are too long to
begin with.

If of course you write routines of several hundreds of lines (or thousands),
then you probably would need to have such a feature.

But I would fire any programmer that writes such code anyway, 
since it indicates he cannot think structured.

But probably this whole answer is again too hyperbole :-)

Michael.



More information about the fpc-pascal mailing list