Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-09

Is is impossible to extend a generic class in fpc 2..6.4?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis Poon

Is it impossible to extend a generic class?
I tried to extend a generic class "TFPGMap" in fpl unit.

its original definition is:
generic TFPGMap<TKey, TData> = class(TFPSMap)

I want to extend it by:
generic TMyMap<TKey, TData>=class(TFPGMap )

   end;

I got this error: Generics without specialization cannot be used as a type for a variable

Then I tried:
generic TMyMap<TKey, TData>=class(generic TFPGMap<TKey, TData> )

   end;

but I got Error: Identifier not found "generic"

I know it was not possible in the past. Just want to know whether it is still not possible in fpc 2.6.4.

Thanks.

Dennis

Sven Barth
to Dennis Poon
Dennis Poon wrote 19 lines
Is it impossible to extend a generic class? I tried to extend a generic class "TFPGMap" in fpl unit. its original definition is: generic TFPGMap<TKey, TData> = class(TFPSMap) I want to extend it by: generic TMyMap<TKey, TData>=class(TFPGMap ) end; I got this error: Generics without specialization cannot be used as a type for a variable Then I tried: generic TMyMap<TKey, TData>=class(generic TFPGMap<TKey, TData> ) end; but I got Error: Identifier not found "generic"

The correct syntax would be:

=== code begin ===

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

=== code end ===

I know it was not possible in the past. Just want to know whether it is still not possible in fpc 2.6.4.

2.6.4 has received *no* fixes related to generics compared to 2.6.0 or 2.6.2.

Regards,
Sven