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

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to