[fpc-pascal] Generic type declaration example versus manual.

Michael Van Canneyt michael at freepascal.org
Mon Nov 23 09:42:27 CET 2009



On Sun, 22 Nov 2009, Anthony Walter wrote:

> On Sun, Nov 22, 2009 at 12:03 PM, Michael Van Canneyt
> <michael at freepascal.org> wrote:
>> Well, in
>>
>> Var
>>  A : Integer;
>>
>> The 'Var' is strictly speaking also redundant, as the : is used only in
>> variable declarations. But the 'var' makes it easier to read, and Pascal is
>> a verbose language. Additionally, the parsing is easier to do, as you know
>> what to expect next. By that rationale, the 'generic' keyword was deemed
>> appropriate when FPC made it's implementation.
>>
>> We'll resolve the incompatibility - remaining backwards compatible to FPC
>> itself - when someone finds the time and desire to do so.
>>
>> Or when someone from our beloved users sends us a patch to this effect.
>
> Michael,
>
> Actually, you are pretty far off. I've written a few parsers for
> Delphi and before generics it has ALWAYS gone like this:

I don't see how "I am far off" since you are saying the same as I am. 
Namely that the verbosity is a benefit.

None of this refutes the observation that - strictly speaking - var, type 
and whatnot are redundant, since it is perfectly possible to determine
from
   A : Integer;
that this statement/line contains a variable declaration, so the 'Var' in
front of it is not needed for the correct functioning of the compiler.

We only differ in that the 'generic' keyword interrupts the 'identifier
expected' logic after the 'Type' keyword. So I can see the benefit of 
removing the generic keyword.

In fact, I'm a proponent of removing generics altogether, but that's 
another story :)

Michael.


More information about the fpc-pascal mailing list