In Delphi 2009, Embarcadero added the anonymous method to the Delphi language.
How is it implemented?
Internally, it is implemented as an interface which implements a single method, Invoke.
So if you have IX declared as reference to procedure, then IX is technically equivalent to the following:
IX = interface procedure Invoke; end;
And if you have IX declared as reference to function: Integer, you would have IX being technically equivalent to:
IX = interface function Invoke: Integer; end;
With IX being declared as reference to procedure, let's declare a class, TX:
TX = class(TInterfacedObject, IX) public procedure Invoke; end; procedure TX.Invoke; begin WriteLn('Hello World'); end; var LX: TX; AX: IX; begin LX := TX.Create; AX := LX; AX; end.
In 2017, with the release of Delphi 10.2 Tokyo, Embarcadero introduced a specialized implementation of the Observer pattern into the System.Classes unit. While it has been in the wild for 9 years, it remains a "hidden" architecture for many, primarily because it serves as the invisible engine behind LiveBindings. Other than live bindings, you can also use the Observer pattern as a way to update component settings to the Windows registry, an .ini file, or persist it elsewhere.
System.Classes