[fpc-devel] Function variables and overload
Marcel Martin
mm10 at ellipsa.net
Fri Jul 1 19:41:40 CEST 2005
Hello,
Let's say there is a function
function ICmp(A,B: PBigInt): SInt32;
and a TBigIntList class having the following method that can
sort the list according to Cmp
procedure TBigIntList.Sort(Cmp: TBigIntCompareFunc);
with, of course,
type TBigIntCompareFunc = function(A,B: PBigInt): SInt32;
Now, if ICmp is not overloaded, there is no problem, the call
L.Sort(@ICmp);
works. But, of course, it doesn't work if ICmp is overloaded.
In fact, we cannot have both overloaded functions _and_ the
the possibility to use them as variables. Yes, there are
ways to fix the problem (no overload or embedding the
overloaded functions in local functions) but none is really
satisfying.
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
exactly know which overloaded function it has to use.
When I ask 'would it be possible', I mean 'would it be possible
without having to rewite all the compiler' ;-)
mm
More information about the fpc-devel
mailing list