[fpc-devel] Function variables and overload

Peter Vreman peter at freepascal.org
Sat Jul 2 22:49:27 CEST 2005


At 22:45 1-7-2005, you wrote:
>Peter Vreman wrote:
>>>Would it be possible to get something like
>>>
>>>  L.Sort(@ICmp(PBigInt,PBigInt));
>>>
>>>in case ICmp is overloaded? If we could add the parameter
>>>types, there would be no more ambiguity, the compiler would
>>There is ambiguity with a normal call to the function. The compiler sees
>>the ( and thinks it is parsing a call to Icmp().
>
>So, perhaps it would be nice if there was a way to declare an alias for 
>overloaded functions? E.g.
>
>
>type
>  TNoParamFunc = function:boolean;
>  TIntParamFunc = function(i:integer):boolean;
>
>function MyOverloadedFunc:boolean; alias MyOverLoadedFuncNoParams;
>function MyOverloadedFunc(i:integer):boolean; alias MyOverLoadedFuncInt;

You can already do this, only with some extra typing:

function MyOverloadedFunc:boolean; public name 'MyOverLoadedFuncNoParams';
function MyOverloadedFunc(i:integer):boolean; public name 
'MyOverLoadedFuncInt';

function MyOverLoadedFuncNoParams:boolean; external name 
'MyOverLoadedFuncNoParams';
function MyOverLoadedFuncInt(i:integer):boolean; external name 
'MyOverLoadedFuncInt';


Peter





More information about the fpc-devel mailing list