I understand that there are special actions to maintaining the lifetime of a outer variable when it was mentioned inside an anonymous procedure. But when the anonymous procedure doesn't use outer variables, will it generate the same assembly call as the good old general procedure. In other words, will the internals of the anonymous function in the Fragment 1 and NamedFunction from fragment 2 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.