[fpc-devel] generics defy scoping rules -- Intended?
Hairy Pixels
genericptr at gmail.com
Tue Nov 25 14:30:37 CET 2025
On Nov 25, 2025 at 4:48:52 PM, Michael Van Canneyt via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:
> Delphi allows to overload a generic with a non-generic class.
>
> TFoo = class end;
> TFoo <a> = class F: a end;
>
> FPC has experimental support for this as far as I know.
>
> So the answer would be:
> Yes, the specialize will look for a generic definition, ignoring classes
> with the same name that are not generic.
>
specialize TFoo<byte> actually searches for the symbol "TFoo$1" so it's a
different symbol name than just TFoo.
I think though if tried to declare TFoo like "a: TFoo" it would give an
error that generics can't be used without specialization thus make using
TFoo unusable, but I may be wrong about that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20251125/6cdb6033/attachment.htm>
More information about the fpc-devel
mailing list