I understand that there are special actions to maintain the lifetime of an external variable when it is mentioned inside an anonymous procedure. But when an anonymous procedure does not use external variables, does it generate the same assembly call as the old general procedure. In other words, the interiors of the anonymous function in fragment 1 and the NamedFunction from fragment 2 will be the same
Fragment 1
type
TSimpleFunction = reference to function(x: string): Integer;
begin
y1 := function(x: string): Integer
begin
Result := Length(x);
end;
y1('test');
end.
Fragment 1
type
TWellKnownSimpleFunction = function(x: string): Integer;
function NamedFunction(x: string): Integer;
begin
Result := Length(x);
end;
var
y1: TWellKnownSimpleFunction;
begin
y1:=NamedFunction;
y1('test');
end.
source
share