3
我明白,在匿名程序中提到它时,有特殊的操作来维护外部变量的生命周期。但是,当匿名过程不使用外部变量时,它是否会生成与旧的一般过程相同的程序集调用。换言之,将匿名函数的在片段1和NamedFunction从片段2的内部是相同当没有外部上下文时,过程变量和匿名函数是否等价?
片段1
type
TSimpleFunction = reference to function(x: string): Integer;
begin
y1 := function(x: string): Integer
begin
Result := Length(x);
end;
y1('test');
end.
片段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.