[fpc-pascal] Typecasting by accident
memsom at interalpha.co.uk
Tue May 16 00:21:12 CEST 2006
> No. Typecasts, as any other aspect of a language, has to have rules.
> AFAIR this cast in Delphi would require another cast from AnsiString
> to Pointer. And if typed pointers is enabled would require another
> cast from Pointer to TObject.
Nope. The C style cast is not type safe. Using the "as" operator is.
i := 10;
p := TObject(i); //will work, but is invalid
p := (i as TObject); //should fail (not tried) because i is not compatible
More information about the fpc-pascal