rtti cast

downs default_357-line at yahoo.de
Sat May 3 19:22:20 PDT 2008


terranium wrote:
> Pragma Wrote:
> 
>> If you absolutely need an exception
> 
> And who don't? Yet another D misdesign to be worked around? And where will be more legacy design typos in the end? In C++ or in D?

Actually, since you don't know if the cast is really valid, it failing is a regular outcome.

As such, an exception (which is reserved, appropriately, for *exceptional* events), is totally the wrong approach to use.

Note that with the current behavior, you can incur the runtime speed loss of throwing an exception if you _want_ to, by using the above templated wrapper, but if throwing an exception were the only possibility, you couldn't possibly get that speed back.

So it really is better this way. :)

 --downs



More information about the Digitalmars-d mailing list