[fpc-pascal] Implicit generic specializations
Ryan Joseph
ryan at thealchemistguild.com
Mon Dec 3 14:01:54 CET 2018
> On Dec 3, 2018, at 2:45 PM, Ryan Joseph <ryan at thealchemistguild.com> wrote:
>
> I just looked it over and I was wrong about the dummy, it’s just a flag. If the generic doesn’t cover existing functions then that messes up some assumptions I made so I need re-think the design now.
I believe I managed to solve the problem and now non-generic procedures take precedence. I guess it’s possible that you could opt out of an implicit specialization now but declaring and overload which the specific type you were interested in. This is probably a good fallback to have so it’s good it’s like this now.
{$mode objfpc}
{$modeswitch implicitgenerics}
program gi_implicit_overload;
procedure DoThis(msg:integer);overload;
begin
writeln('DoThis:',msg);
end;
generic procedure DoThis<T>(msg:T);overload;
begin
writeln('DoThis$1:',msg);
end;
begin
DoThis(1); // DoThis:1
DoThis('string’); // DoThis$1:string
end.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list