Re:Real cost of C++ exception vs error-code checking
by supersillyus on Tuesday March 08, 2011 @01:33PM
(#2302011)
I don't know that it's accurate to compare C++ exception specifications with Java-style checked exceptions. Exception specifications aren't checked at compile time and typically don't do what you want at runtime.
Re:Real cost of C++ exception vs error-code checking
by snprbob86 on Tuesday March 08, 2011 @02:10PM
(#2302160)
shrug You're probably right. I've never really used them in C++, especially because I tend to avoid C++ in favor of the smallest possible amount of C to bootstrap primary use of a much higher level language.
Re:Real cost of C++ exception vs error-code checking
by cpeterso on Tuesday March 08, 2011 @08:53PM
(#2303452)
As mentioned, C++ exception specifications are checked at run-time, not compile-time. And if your function's exception specification declares `throws(FooException)` and you call some third-party library function (which may or may not have its own exception specification!) that throws a `BarException`, C++'s runtime checks will `terminate()` your program!
C++ exceptions and exception specifications are pretty much all the worst possible design decisions. :(
Checked exceptions is a hotly debatted topic and I think the world has kinda finally come around to deciding that the are a bad idea overall. Google it and see for yourself.