Ho una funzione che restituisce una funzione TFunc<Integer>
che è reference to function:Integer
. e ho una procedura che accetta come argomento una funzione TFunc<Integer>
, la chiama e ne stampa il risultato."riferimento alla funzione" come risultato di una funzione
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
function GetFunction:TFunc<Integer>;
begin
result := function:Integer begin result := 42 end;
end;
procedure FunctionCall(AFunc:TFunc<Integer>);
var i:Integer;
begin
i := AFunc;
WriteLn(Format('Function Result = %d',[i]));
end;
begin
// FunctionCall(GetFunction); // error
FunctionCall(GetFunction()); // works as excpected
end.
questa chiamata (FunctionCall(GetFunction);
) restituisce un errore. e la chiamata con ()
funziona come previsto.
la mia domanda è:
quando in Delphi ho bisogno parentesi di chiamare una funzione e quando non (ho pensato che non ho mai bisogno di loro)
o
non dovrebbe ho bisogno di loro ed è un bug?
lavoro con delphi xe5 su windows 7 dcc32.
Posso confermare che non si compila neanche in XE4. –