I stand corrected. I've just checked Delphi5 and indeed it allows a
direct typecast from ansistring to any object/class :-/
But Delphi also allows direct cast from enumeration value to pointer
(which FPC doesn't allow), so maybe this is another nice oportunity to
be stricter than Delphi ;-)

Cheers,
Flávio

On 5/15/06, Matt Emson <[EMAIL PROTECTED]> wrote:

> 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.

var
  p: pointer;
  i: integer;
begin
  i := 10;
  p := TObject(i); //will work, but is invalid
  p := (i as TObject); //should fail (not tried) because i is not compatible
end;

M

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to