[fpc-pascal] generic proc inference
    Michael Van Canneyt 
    michael at freepascal.org
       
    Mon Oct  7 14:37:16 CEST 2019
    
    
  
On Mon, 7 Oct 2019, Mattias Gaertner via fpc-pascal wrote:
> On Mon, 7 Oct 2019 14:12:32 +0200
> Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
>> [...]
>> > > > > generic function DoThis<T>(a: T): T; overload;
>> > > > > begin end;
>> > > > > generic function DoThis<T,U>(a: T): U; overload;
>> > > > > begin end;
>> > > > >
>> > > > > begin
>> > > > >  DoThis(3); // both fits, should give an error
>> > > > > end; 
>> [...]
>> I'm also for an error.
>> 
>> However does Delphi pick a suitable non-generic overload  if one
>> exists aside from the two generic ones?
>
> Can you give an example what you mean?
I think sven means if you have e.g. 3 functions:
generic function DoThis<T>(a: T): T; overload;
begin end;
generic function DoThis<T,U>(a: T): U; overload;
begin end;
function DoThis(aInt : Integer) : Integer;
begin
end;
Should the compiler choose the 3rd non-generic function, or still give an
error ?
Michael.
    
    
More information about the fpc-pascal
mailing list