{ %NORUN } program tanonfunc67; {$mode delphi} {$modeswitch anonymousfunctions} {$modeswitch functionreferences} {$modeswitch advancedrecords} { test advanced generics same as tanonfunc41 but mode delphi } type M = reference to function (const A: T): M; type G = record type M = reference to function (const A: T): M; end; type C = class(TInterfacedObject, M) function Invoke(const A: T): M; end; function C.Invoke(const A: T): M; begin Writeln(ClassName, '.Invoke(', A, ')'); Result := Self; end; type R = record procedure Foo; procedure Foo; end; procedure R.Foo; type Local = reference to procedure (const X: T); var Z: Local; // TODO: var AZ: reference to procedure (const X: T); begin Z := procedure (const C: Char) begin WriteLn('nmls: ', C) end; Z('Z') end; procedure R.Foo; type Local = reference to procedure (const X: T); var l: Local; begin l := procedure(const X: T) begin end; l(Default(T)); // TODO: nameless routines in generics end; var X: M{G.M}; Y: R; begin X := C.Create; X(42)(777)(1024); Y.Foo; end.