[fpc-pascal] generic proc inference
Ryan Joseph
genericptr at gmail.com
Mon Oct 7 22:35:42 CEST 2019
> On Oct 7, 2019, at 12:42 PM, Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
>> I mean what happens here? The non-generic functions wins right?
>>
>> procedure Run<T>(a:T; b: word);
>> procedure Run<T>(a: word; b: T);
>> procedure Run(a: word; b: word);
>
> Only for
> Run(word(1),word(2));
Ok, then I got this wrong and I need to make significant changes. As I did it if there is a non-generic it always wins regardless of parameters. For example:
procedure Run(a: integer; b: string);
begin
end;
generic procedure Run<S,T>(a: S; b: T; c: integer);
begin
end;
// fails because the non-generic Run() will always be picked and the parameter count will be wrong.
Run(1,1,1);
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list