mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 05:18:14 +02:00
34 lines
449 B
ObjectPascal
34 lines
449 B
ObjectPascal
program tanonfunc65;
|
|
|
|
{$mode delphi}
|
|
{$modeswitch anonymousfunctions}
|
|
{$modeswitch functionreferences}
|
|
|
|
{ test generic anonymous method reference
|
|
|
|
same as tanonfunc34 but with mode delphi
|
|
}
|
|
|
|
type
|
|
TProc<T> = reference to procedure(Arg: T);
|
|
|
|
procedure Foo;
|
|
var
|
|
p: TProc<Integer>;
|
|
acc: Integer;
|
|
begin
|
|
p := procedure(Arg: Integer)
|
|
begin
|
|
Inc(acc, Arg);
|
|
end;
|
|
acc := 1;
|
|
p(2);
|
|
if acc <> 3 then
|
|
halt(1);
|
|
end;
|
|
|
|
begin
|
|
Foo;
|
|
end.
|
|
|