[fpc-pascal] Interface syntax: Is possible don't use specialize in mode objfpc?

Michael Van Canneyt michael at freepascal.org
Thu Jul 16 19:21:23 CEST 2015



On Thu, 16 Jul 2015, Marcos Douglas wrote:

> On Thu, Jul 16, 2015 at 11:44 AM, Michael Van Canneyt
> <michael at freepascal.org> wrote:
>>
>>
>> On Thu, 16 Jul 2015, Maciej Izak wrote:
>>
>>> sadly - no, only in Delphi mode. btw. this thing keep me away from objfpc.
>>
>>
>> That seems like a very strange reason to me.
>>
>> The fact that you must type 1 word in certain places keeps you from using an
>> otherwise useful mode ?
>> This word is there for clarity, It is meant to help you, to make explicit
>> you are in fact specializing a new type.
>
> Yes, but do you think this is more verbose unnecessarily? Because the
> syntax TFoo<T> (I mean this "<>") show us that is a generic, don't?
>
> The Lazarus also has some troubles with the code completion using this:
> TFoo = class(TInterfacedObject, specialize ICloneable<TFoo>)

Lazarus is not alone, even I have trouble with this :)

>
> Sometimes the IDE shows an error in interface declaration, but compiles.
> So, to not receive these errors I have to create a new type:
>
> TFoo = class; //forward
>
> IFooCloneable = specialize ICloneable<TFoo>;
>
> TFoo = class(TInterfacedObject, IFooCloneable)
> //...
> end;
> ...making even more verbose.

Pascal is a verbose language. If you want terse, use C++ or something like it.

The whole generics mess that Delphi made goes completely against the Pascal 
dictum that you must declare something before you can use it.

To me, the above verbose construction makes absolute sense. It has been so since day 1:

PRecord = ^TRecord;
TRecord = record
   a : integer;
   next : PRecord;
end;

Michael.



More information about the fpc-pascal mailing list