[fpc-pascal] Generics feature status

Paul Ishenin webpirat at mail.ru
Sat Apr 30 03:15:54 CEST 2011


30.04.2011 3:28, leledumbo wrote:
> I see now that generics have improved a lot since latest release, we even
> have Delphi compatible syntax in Delphi mode. Recursive generic type is
> supported as well now (finally, I can continue my data structure library
> :)). Seeing these facts, what's the status of this feature now? Is it
> considered stable?--
No, they are not stable. FPC generic syntax may change. But you can rely 
on delphi syntax (as we can't change it) with few limitations at the moment:
  - no multiply generics with the same identifier and different amount 
of type parameters [1],
  - no generic methods,
  - no type constraints.

Also I may forgot something.

About [1] - in delphi it is possible to define different generics with 
the same identifier and different amount of type parameteres (even in 
the same unit). E.g.
TList = class ...; TList<T> = class ...; TList<T, TT> = class ...;

Then you can declare variables with any of that types. E.g.
var
   L: TList;
   LI: TList<Integer>;
   LIO: TList<Integer,TObject>

As I know Sven will work to support this and other missing generics 
features.

Best regards,
Paul Ishenin



More information about the fpc-pascal mailing list