Re: [fpc-pascal] Typecasting by accident

2006-05-20 Thread Flávio Etrusco
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 ;-) Cheer

Re: [fpc-pascal] Typecasting by accident

2006-05-19 Thread Flávio Etrusco
I stand corrected. I've checked Delphi5 today and none of my expectations where correct :-( Of course I think that AnsiString being a native type would require that (one) typecast just like any other (native type). Of course I also think that any object should be cast to a mininum common ancestor

Re: [fpc-pascal] Typecasting by accident

2006-05-15 Thread Matt Emson
> 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

Re: [fpc-pascal] Typecasting by accident

2006-05-15 Thread Jonas Maebe
On 15 mei 2006, at 18:09, Flávio Etrusco wrote: It's a CAST dude! Exception_Message is being case as Not_Now. That should work fairly well in most dialects.t No. Typecasts, as any other aspect of a language, has to have rules. AFAIR this cast in Delphi would require another cast from AnsiSt

Re: [fpc-pascal] Typecasting by accident

2006-05-15 Thread Flávio Etrusco
On 5/14/06, Matt Emson <[EMAIL PROTECTED]> wrote: > Weird, I wouldn't expect OBJFPC mode to allow automatic conversion > from AnsiString to Pointer... Um... > raise Not_Now (Exception_Message); It's a CAST dude! Exception_Message is being case as Not_Now. That should work fairly well in m

Re: [fpc-pascal] Typecasting by accident

2006-05-14 Thread Matt Emson
> Weird, I wouldn't expect OBJFPC mode to allow automatic conversion > from AnsiString to Pointer... Um... > raise Not_Now (Exception_Message); It's a CAST dude! Exception_Message is being case as Not_Now. That should work fairly well in most dialects.t M

Re: [fpc-pascal] Typecasting by accident

2006-05-12 Thread Flávio Etrusco
Weird, I wouldn't expect OBJFPC mode to allow automatic conversion from AnsiString to Pointer... -Flávio On 5/12/06, Vinzent Hoefler <[EMAIL PROTECTED]> wrote: Just found a bug of mine I was wondering about since about three days, and wanted to share the fun with you: -- 8< -- // "How to rais

Re: [fpc-pascal] Typecasting by accident

2006-05-12 Thread memsom
> raise Not_Now (Exception_Message); I feel your pain! far too much like : throw Not_Now(Exception_Message); My brain does this all the time moving between C# and Delphi. The one I always seem to do, is "except" instead of "catch" in "try" blocks. At least the compiler/syntax checker get

[fpc-pascal] Typecasting by accident

2006-05-12 Thread Vinzent Hoefler
Just found a bug of mine I was wondering about since about three days, and wanted to share the fun with you: -- 8< -- // "How to raise the wrong exception" or // "Why automatic type conversion really sucks" {$MODE OBJFPC} program Exception_Fun; uses SysUtils; function Exception_Messa