[fpc-pascal] Generics feature status

Sven Barth pascaldragon at googlemail.com
Sun May 1 00:15:19 CEST 2011


On 30.04.2011 03:15, Paul Ishenin wrote:
> 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.

Point 1 is already on a good way - with backwards compatible FPC syntax 
:) The only thing that still scares me are those nasty inline 
declarations -.-

Type constraints (at least non-interface ones) should be rather easy to 
do. The hardest part might be the parsing.

Regarding generic methods: I've already found the points where I'll need 
to hook in and keep those in mind while extending/adjusting the existing 
code, but that's it currently.

Regards,
Sven



More information about the fpc-pascal mailing list