I have two Equal method that take these overloads:
TVariantExpression = reference to function(): Variant;
function Equal(const value: Variant): TRuleBuilder; overload;
function Equal(expr: TVariantExpression): TRuleBuilder; overload;
suppose I have another function :
function TForm1.GetMagicNumber: Variant;
begin
Result := 10;
end;
and I invoke function like this:
Equal(Form1.GetMagicNumber);
After inspecting, I get result that second overload is called. Why? because both of them is valid to be called.
is ambiguous. It can be either the function, or the value returned after executing the function. In most contexts, only one of those meanings is valid, and that meaning is chosen.
In your code, either meaning is valid. In such a scenario the language rules mean that the procedural type interpretation is chosen.
To force function invocation write:
This is a significant difference from most other languages, e.g. C, C++, C#, Java, Python etc. In those languages you must use parentheses in order to invoke a function.