[fpc-devel] Thoughts on being able to declare "pointer-to-type" parameters directly in method signatures?

Sven Barth pascaldragon at googlemail.com
Fri Jun 7 22:51:32 CEST 2019

Am 07.06.2019 um 22:45 schrieb Ryan Joseph:
>> On Jun 7, 2019, at 3:50 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>>    generic procedure MemCopy<T>(Dest, Src: specialize TPointerType<T>.PT; Len: PtrUInt);
>>    begin
>>      while Len > 0 do begin
>>        Dest^ := Src^;
>>        Inc(Dest);
>>        Inc(Src);
>>        Dec(Len);
>>      end;
>>    end;
> May I ask where the syntax for “specialize” came from? Delphi doesn’t use it nor does any other language out there. Honestly it’s extremely verbose and makes me want to avoid generics sometimes. I just don’t get it. I will say that I like the “generic” addition to type declarations though because it makes it more clear what they are.
It has been part of FPC from the beginning of generics. It allows the 
parser to differentiate easier that a specialization is following. This 
was less important when only type declarations could contain 
specializations, but nowadays with support for inline specializations 
this is especially true as something with "<" in it is not always easy 
to differentiate between a specialization and an expression. Case in 
point: Delphi mode doesn't yet support all kinds of expressions 
containing specializations that mode ObjFPC supports.


More information about the fpc-devel mailing list