In general, I originally wanted to do this kind of “
convert” an
anonymous function into a
methodAnd the fact that now the first argument is passed to
RDX is even to my advantage, so I withdraw my wishes

I'm happy with everything now, but there is room for discussion, of course

program app;
{$mode objfpc}
{$modeswitch anonymousfunctions}
uses Classes;
generic function AnonymToMethod<T>(AObj: Tobject; const AnonProc): T;
begin
TMethod(Result).Code:=@AnonProc;
TMethod(Result).Data:=AObj;
end;
var
SL: TStringList;
begin
SL := TStringList.Create;
SL.OnChange:=specialize AnonymToMethod<TNotifyEvent>(SL,
procedure (Sender: TObject)
begin
WriteLn((Sender as TStringList).Count);
end);
SL.Add('1');
SL.Add('2');
SL.Add('3');
ReadLn;
end.