I use type
type
TRealFunction = reference to function(const X: extended): extended;
a lot in my code. Suppose I have a variable
var
rfcn: TRealFunction;
and try to assign it Math.ArcSec:
rfcn := ArcSec;
This works the same as expected in Delphi 2009, but now I tried to compile it in Delphi 10.2 and the compiler is upset:
[dcc32 Error] Unit1.pas(42): E2010 Incompatible types: 'TRealFunction' and 'ArcSec'
The difference seems to be that it is ArcSecoverloaded in Delphi 10.2: it is found in single, doubleand extendedvariants. It seems that the compiler does not like references to overloaded functions (or procedures) of this kind (too similar types?).
However, if I redefine
type
TRealFunction = function(const X: extended): extended;
it just compiles.
Of course, there are obvious workarounds here: I could identify
function ArcSec(const X: extended): extended; inline;
begin
result := Math.ArcSec(X);
end;
or I could just write
rfcn := function(const X: extended): extended
begin
result := Math.ArcSec(x);
end;
However, this is a lot of code for writing. Is there an easier way around this?