[fpc-pascal] Generics in Objective Pascal?

Zoë Peterson zoe at scootersoftware.com
Sun Nov 1 16:45:08 CET 2020

I'd like to have a generic objcclass that would add some extra 
functionality for multiple base types.  I don't have a lot of experience 
with generics, but this compiles:
generic TMyControl<T: TWinControl> = class(T)
     FField: string;
procedure Foo;
   TMyEdit = specialize TMyControl<TEdit>;

and this fails with the error 'Class or interface type expected, but got 
   generic NSMyView<T: NSView> = objcclass(T)
     FField: string;
     procedure Foo; message 'Foo:';

The documentation doesn't mention it, so I'm assuming it's just not 
implemented.  Is that something that could be supported?  Would it be 
difficult to do so?  Are there any existing Objective Pascal specific 
tricks I could use to avoid duplicating all of the fields/code?
Zoë Peterson
Scooter Software
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20201101/eebc74c9/attachment.htm>

More information about the fpc-pascal mailing list