> On Jun 1, 2019, at 6:00 AM, Michael Van Canneyt <mich...@freepascal.org> 
> wrote:
> 
> I don't think this syntax is a good idea.
> 
> What with overloads ?
> 
> Procedure MyProc<T>(a:T);
> Procedure MyProc(a : TObject);

Currently the non-generic gets called in this situation. That’s because 
non-generic procedures take precedence and TMyClass can be passed to TObject. 
That’s pretty simple right?

{$mode objfpc}
{$modeswitch implicitfunctionspecialization}

program timpfuncspez14;

type
  TMyClass = class
  end;

procedure DoThis(msg: TObject);
begin
  writeln('DoThis:',msg.ClassName);
end;

generic procedure DoThis<T>(msg: T);
begin
  writeln('DoThis<T>:',msg.ClassName);
end;

begin
  DoThis(TMyClass.Create);
  DoThis(TObject.Create);
end.

Regards,
        Ryan Joseph

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to