Shachar Shemesh wrote:
THE thing that makes me miss C++ the most is exception handling. C
offers you, basically, three options:
1. Having to perform an "if" every other line and perform a *shudder*
goto in case of error.
2. Have nested "if"s seven levels deep.
3. return from the middle of the function.
4. Worst yet, write insecure code.
1. produces the longest code. It is also the ugliest one, structured
programming wise.
Actually, the Linux kernel uses this technique, and it doesn't
always lead to longer code than, say, nested if's. It can
actually be quite clean, and given that the use of 'goto'
is restricted to a very narrow idiom, it's not all that hard to read.
Exceptions, on the other hand, give a clean solution to the entire
problem. ...
Or at least seems to. It's *very* difficult to write C++ code that
is threadsafe and exception safe at the same time.
If the discussion goes forward, I can give an example of rewriting my
latest patch to wineboot (currently using approach 1) with the other
four approaches (2, 3, 4 and exceptions).
I've enjoyed the bit of Wine work I've done, but I'm not sure
I'd continue enjoying it if C++ began to be used inside the
core of Wine. C++ is for applications, not operating systems.
- Dan
--
Dan Kegel
Linux User #78045
http://www.kegel.com