[fpc-devel] Attn: Sven Can not use "specialize" to resolve forward declaration
Sven Barth
pascaldragon at googlemail.com
Thu Dec 9 07:59:31 CET 2021
Martin Frb via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Do.,
9. Dez. 2021, 00:15:
> https://gitlab.com/freepascal.org/fpc/source/-/issues/39459
> You wrote
> >> No, this can not and this will never work. When a generic parameter has
> a constraint that constraint *must* be adhered to and a forward
> declaration is *not* a valid type for such a constraint (except for
> *class* / TObject constraints).
>
> Using TObject for just any class is nice here.
>
> What to use for interface?
> https://gitlab.com/freepascal.org/fpc/source/-/issues/39459#note_758496897
>
> Sorry replied on the wrong issue.
>
>
> How can I restrain a generic param, so it must be an interface, but leave
> open the exact type, so I can later use a forward declaration?
>
For interfaces you can use IInterface/IUnknown though that will work only
for COM interfaces. For raw interfaces there is no solution currently.
In my opinion you should rethink your code structure however. I don't know
right now what would be better, but as it is now it feels bad.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20211209/084dee4a/attachment.htm>
More information about the fpc-devel
mailing list