Passing a method's code as an argument in a typesafe way
问题 Passing a method as an argument is not a problem: type TSomething = class Msg: string; procedure Show; end; procedure TSomething.Show; begin ShowMessage(Msg); end; type TProc = procedure of object; procedure Test(Proc: TProc); begin Proc; end; procedure TForm1.Button1Click(Sender: TObject); var Smth: TSomething; begin Smth:= TSomething.Create; Smth.Msg:= 'Hello'; Test(Smth.Show); end; I need something tricky - to pass only a code part of a method. I know I can do it: procedure Test2(Code: