[fpc-devel] generics defy scoping rules -- Intended?
Sven Barth
pascaldragon at googlemail.com
Tue Nov 25 18:53:19 CET 2025
Martin Frb via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Di.,
25. Nov. 2025, 15:55:
> On 25/11/2025 14:19, Sven Barth via fpc-devel wrote:
>
>
>
> Yes, because in fact they don't have the same name. The name of a generic
> with a single parameter is essentially "TFoo<>" while that of a generic
> with two parameters is "TFoo<,>".
>
> The amount of generic parameters is part of the type or routine name.
>
>
> Thanks, which just for confirmation brings up a follow up question. (I
> haven't used generic function much yet, so maybe I miss something)
>
> function Foo (aParam: Integer): integer;
> generic function Foo<T>(aParam: t) : integer;
>
>
> Those are 2 different function too? (not an overload? because "T" could be
> integer in same cases)
>
> Do you then always have to call the generic using
> specialize Foo<integer>(1)
> ?
>
Correct. It doesn't matter what the generic might be specialized to, the
generic is definitely a separate routine from the non-generic one and not
an overload.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20251125/a270b7ca/attachment-0001.htm>
More information about the fpc-devel
mailing list