rtti cast

terranium spam at here.lot
Thu May 8 06:23:54 PDT 2008


BCS Wrote:

> >>I perform downcasts extremely rarely.
> > 
> > That's *exactly* why you need safe cast.
> > 
> 
> How does that follow? I don't see the connection.

When you do some unusual thing, the probability of mistake increases.

> And this will result in a Seg-V. The program will stop in a predictable 
> manner. IMHO (and it seems others opinions) that is what matters.

The program will not stop in a predictable manner since a third party library can silently handle nulls, e.g. XML serialization. And if it stops in an AV this happens in an unpredictable location - miles away from the place where the bug was triggered. What matters is a presence of bugs, to solve this you must eliminate them, to eliminate them you should know, where the bug was triggered (and of course you need to know that there is a bug), to help locating bug an exception should be thrown as soon as possible after the bug was triggered, ideally exception should be thrown in the same location, where the bug was triggered.



More information about the Digitalmars-d mailing list