When casting is not used with object pointers, it normally means to simply copy the data between incompatible types without converting the data or flagging an error. Bascially, this allows the programer to override the compiler's error checking.
i = CInt(f) ' Converts f to an integer
A straight cast is evaluated at compile time. When as is used with an object, additional code is generated to verify at run time that the new type is a base class of the referenced object.
i := integer(f) ; // Treats f as an integer i := f as integer ; // Fails with non-object types with Sender as TButton do // Parentheses are not required here with TButton (Sender) do (Sender as TButton).Caption := '&Ok'; // Parentheses are required here TButton(Sender).Caption := '&Ok'; // Parentheses are required here
a = (char)i; // Treat i as a char and assign it to a