www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



digitalmars.D - Re: rtti cast

↑ ↓ ← terranium <spam here.lot> writes:
downs Wrote:

 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.
 

May 07 2008
↑ ↓ → BCS <BCS pathlink.com> writes:
terranium wrote:
 downs Wrote:
 
 
As such, an exception (which is reserved, appropriately, for *exceptional*
events), is totally the wrong approach to use.

Yes, function received wrong input, this is normal, if we want, we throw exception, if we want, we ignore it.

The point is that offtent a failed cast is not an indecation of an error. For instance code like this class A {} class B1 : A {} class B2 : A {} void foo(A a) { if(auto b = cast(B1)a) {} else if(auto b = cast(B2)a) {} else {} }
May 07 2008