Exceptions
I would like to see API wide use of exceptions for errors (where ever possible). I understand that you can't use exceptions in system level code (e.g. kernel), but the 'new' operator already throws an exception if it encounters an error. This makes it difficult to write clean constructors since everything else returns error codes. I think that in general creating objects on the stack (when ever possible) and throwing exceptions makes for cleaner code (at least execution wise). That way if an error is encountered and an exception is thrown the stack is unwound for you automagically and you don't have to worry about empty pointers or orphaned objects. Error code returns from functions seems so 1995 to me. Death to status_t!
Either way, the bottom line is: YOU SHOULD BE CATCHING EXCEPTIONS! The 'new' operator throws them...period.
References:
Using C++ in the kernel
BeNewsletter, Volume III, Issue 51
(I thought there were some articles about exceptions and the 'new' operator, too. Can't find 'em.)
-- Paul J. Stadig
Some info can be found in Effective C++, Item 7.
IndexPage | TableOfContents