myObject.MyEvent := procedure (Sender : TObject); begin ... end;
There are of course some extensions that go beyond what Delphi supports 😉
You are allowed to use a named local procedure as a closure / anonymous method, with optional capture of local variables, allowing for neater layout of code, for instance:
begin ... procedure MyLocalProc(Sender : TObject); begin ... end; ... myObject.MyEvent := MyLocalProc; ... end;
The function pointers and closures are unified, you did not have to distinguish between a “procedure” and a “procedure of object“, and you don’t have to distinguish a “reference to procedure” either, ie. if you declare
type TNotifyEvent = procedure (Sender : TObject);
as long as the parameters match (and result type for a function) , the above type will accept standalone functions, object methods, interface methods, and now closures/anonymous methods (and even record methods, which are just syntax sugar for standalone function with an implicit parameter).