[fpc-pascal] how to define a generic subclass inheriting from another generic class?

Sven Barth pascaldragon at googlemail.com
Tue Dec 10 14:22:36 CET 2013


Am 10.12.2013 11:53 schrieb "Dennis Poon" <dennis at avidsoft.com.hk>:
>
> What is the syntax. I could not find it in google.
>
> e.g. in unit fgl,
>
>
> generic TFPGMap<TKey, TData>=class(TFPSMap)
> ....
> end;
>
>
> How do I define a subclass TMyMap inheriting from TFPGMap without first
specializing it?
>
> I assumed
>
> generic TMyMap <TKey, TData> = class(generic TFPGMap<TKey, TData>)
> ...
> end
>
> but fpc 2.6.2 did not accept this.
>
> Please help.

The pre-2.7.1 compilers don't support this. In 2.7.1 the syntax is:

generic TMyMap <TKey, TData> = class(specialize TFPGMap<TKey, TData>)
   //...
end;

(and yes, it's "specialize", not "generic" and it's working as intended)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131210/93da456d/attachment.html>


More information about the fpc-pascal mailing list