[fpc-pascal] Syntax changes suggestions

Sven Barth pascaldragon at googlemail.com
Mon Jul 16 19:55:15 CEST 2018


Santiago A. <svaa at ciberpiula.net> schrieb am Mo., 16. Juli 2018, 16:27:

> El 16/07/2018 a las 15:02, Sven Barth via fpc-pascal escribió:
>
> 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
>
> I think the opposite.
> The nearer the declaration to the code where you use it, the better.
>

I disagree. The way it is in Pascal you can easily see which variables are
used and what type they have while with inline declarations you need to
skim the whole routine. And trust me, only because a variable *can* be
declared close to its use it does not mean that it *is*.


>
> - Autofree pointers
>>
> Might come, though not in that way (take your example: what if you pass
> the instance to some other code that stores it beyond the life time of the
> function)
>
> In such cases, you don't declare it "auto". Just as you don't free a
> pointer in the function you declare it if you pass the instance to another
> code that stores it beyond the life time of the function
>

But you don't necessarily know that the function you call does that (think
third party code). And people *will* use this and don't think about the
consequences. So a system with automatic reference counting is safer and
that is what is planned, if at all.


>
> - Try except finally blocks
>>
> This had been proposed some time ago and was declined after quite some
> discussion (either here or on fpc-devel).
>
> - Private declarations in implementation
>>
> Again this reduces readability and thus no interest.
>
>
> Once again, I think the opposite.
> It's not very readable a class where you have to skim through 100 lines of
> private declaration that you don't care, because you can do nothing with
> them.
>

Again all the declarations reside in one place currently, namely the
declaration of the class. With your idea I'd have to search the whole unit
not to mention that the order of declaration would be important as well
just like it had been in procedural Pascal due to the single pass nature of
the language.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180716/94c4b0da/attachment.html>


More information about the fpc-pascal mailing list