> On Dec 2, 2018, at 10:53 PM, Sven Barth via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> Specialization is expensive. If specialization can be avoided, it should be. 
> Not to mention that the non-generic one could have more optimized code. 
> Though to be sure I'll test with Delphi, we'll have to be compatible there 
> anyway. 
> 

I think the “dummy” sym which is added after the generic procedure is 
overwriting the existing symbols. In the example below (my code disabled now) 
DoThis gives an error because it thinks DoThis is the dummy sym. If we want 
this to work the dummy needs to keep track of existing procsyms, unless there’s 
another way to get that information?

Personally I’m fine with this because I didn’t expect to be mixing generic 
procedures anyways.

procedure DoThis(msg:integer);
begin
        writeln('DoThis:',msg);
end;

procedure DoThis(msg:string);
begin
        writeln('DoThis:',msg);
end;

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

begin
        DoThis('a’); // ERROR: "Generics without specialization cannot be used 
as a type for a variable"
end.

Regards,
        Ryan Joseph

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

Reply via email to