[fpc-pascal] generic proc inference
Ryan Joseph
genericptr at gmail.com
Mon Oct 7 15:38:45 CEST 2019
> On Oct 7, 2019, at 5:39 AM, Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> I'm baffled. That's more basic algorithm than I expected. ;)
All contributions are welcome. It sounds like we need make some changes or overhaul the entire thing.
>
> This means you don't support:
> generic procedure Run<S,T>(a: T; b:S); overload;
That’s correct, this breaks the logic entirely. This to me looks like a sneaky way to trick the compiler and since it’s trying to infer something from the programmer it doesn’t make sense. If you have a better algorithm please post.
>
> And the following compiles, but fails on run, as T becomes an array
> instead of the element type:
> generic procedure Run<T>(a: array of T); overload;
>
Good catch, that’s a bug.
var
a: array of integer;
begin
Run(a);
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list