Dan Kegel wrote:
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.
I use that for kernel programming too, sometimes.
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.
I'll have to think about that one.
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.
I don't think that inside the core is a good idea either (except in places where the "core" is a huge application, such as may happen if we integrate a web browser in). I was thinking about the peripherial apps, though.
- Dan
Shachar