Now you can declare initialized global instance variables and constants of class types in the Delphi for .NET Language! Not supported in Delphi for Win32.
WARNING! As this is undocumented, it may not be supported in future releases.
var Button: TButton = TButton.Create(nil);
Supported since Delphi 8? Tested on Delphi 2005 and Delphi 2006.
Here's a complete example.
{$APPTYPE CONSOLE}
{%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Drawing.dll'}
uses SysUtils, StdCtrls;
procedure Test2;const Button1: TButton = TButton.Create(nil);var Button2: TButton = TButton.Create(nil); // This doesn't work, so don't bother.begin
end;
var Button1: TButton = TButton.Create(nil); // This works.const Button2: TButton = TButton.Create(nil);beginend.
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