The Delphi 8 compiler introduces the AUTOBOX directive. In the spirit of the Delphi Language Guide, I have presented information for the AUTOBOX directive in the table below.
Remarks
The $AUTOBOX directive controls the compatibility of simple types with other types.
In the {$AUTOBOX OFF} state, a simple type is compatible with only that simple type. In order for a simple type to be converted to another type, a boxing operation is needed.In order to remain compatible with previous versions of Delphi, this is the default.
In the {$AUTOBOX ON} state, a simple type is compatible with that simple type, and TObject itself. Also, in a call to a procedure with an interface type parameter, an object is compatible with only any interface types it implements, provided that the declared procedure is not overloaded.
Sample usage
var O: TObject; I: Integer;begin I := 5; {$AUTOBOX ON} O := I; {$AUTOBOX OFF} O := TObject(I);end.
Quiz time!
Which of the following code fragments would compile or not compile?
beginFoo(42);end.
beginFoo(TObject(42));end.
Learn why the map is cool in Go!
A method to design records so that they're allocated on a specific byte boundary, such as 16 bytes, 512 bytes, 4096 bytes, etc.
Learn the command line used to compile System.pas in Delphi
How to free more space on your home drive by redirecting the location for SDKs in RAD Studio