rtti cast

terranium spam at here.lot
Wed May 7 05:03:04 PDT 2008


BCS Wrote:

> In most cases forgetting to check the cast return will result in an 
> seg-v from a dereferenced null because you almost always use it as the 

In most cases... almost always... When an invalid cast occurs, the error is not in null pointer it's in invalid cast, and replacing InvalidCastException with a hope for NullPointerException is a wrong way.

> Having the "bad cast" -> null is very handy when you don't known if the 
> cast will be good. It mean you can test it without invoking the 
> exception system and all the overhead that entails.

maybe in this case we need some syntax sugar, not a silent cast?



More information about the Digitalmars-d mailing list