Re: I keep running into long term c++ programmers who refuse to use exceptions
John G Harris <news0@nospam.demon.co.uk> wrote:
Daniel T. wrote:
That's not what I'm arguing... If I had to distill it in one
sentence, I might say something like, "all thrown exceptions should
cause the program to shutdown/reset, possibly saving/cleaning up
issues along the way."
I still don't understand why you think that exceptions *must not* be
used for any other purpose.
"Must not" is a lot stronger than "should," especially when you stress
it... I wouldn't go that far. What I'm saying is the same thing that
Stroustrup says in section 14.5 of "The C++ Programming Language."
Exception handling is a less structured mechanism than local control
structures such as if and for and is often less efficient when an
exception is actually thrown. Therefore, exceptions should be used
only where the more traditional control structures are inelegant or
impossible to use.
...
[Use exceptions as alternate returns] can easily be overused and
lead to obscure code. Whenever reasonable, one should stick to the
"exception handling is error handling" view. When this is done,
code is clearly separated into two categories: ordinary code and
error-handling code. This makes code more comprehensible.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]