begin quoting Gabriel Sechan as of Sun, Jun 10, 2007 at 04:31:58PM -0500:
> >From: Stewart Stremler <[EMAIL PROTECTED]>
>
> >(1) They're not accepted as universal, so "best practices" results in a
> >set of macros to "portably handle exceptions". You don't use try, you
> >use a MACROPREFIX_TRY, and a MACROPREFIX_END_TRY, and all that stuff...
> >plus you have to keep track of nested try-catch blocks, and use custom
> >throw macros, and so forth. It makes the whole exception thing so
> >useless that you might as well not use it at all, which is, I suspect,
> >the point.
>
> Umm, what the hell are you talking about? I have *never* seen any such
> macros used in C++ code. I have never seen a macro to do try, throw, or
> carch ever. And while you can do nested try/catch blocks, you don't need
> to do anything special for them. I have no clue where you're coming from
> here.
Count yourself lucky, then.
Wrapping exception handling in macros for portability (across C++
compilers) gives REALLY ugly C++.
I'm coming from a project with 4,500+ C++ source files that used
ACE/TAO (which is even bigger). Maintaining someone else's C++
code (in anger) is where I'm coming from.
> >(2) You can't get meaningful information from an unknown exception.
> >Sure, you can "catch ( ... )", which will catch an unknown exception,
> >but you have absolutely no way of learning anything at all about that
> >exception. No stack traces for you!
>
> Use an exception base class, and only throw children of that base class.
> There you go- meaningful information.
Let me emphasize the "unknown" part: it's an UNKNOWN exception. I don't
know what code is throwing the exception. It's not code that I've
written or looked at. If I was the one throwing the exception, I'd know
how to catch it, and I wouldn't be using catch (...), and all would be
gravy. But I'm not, so I don't, thus I must, and it ain't.
Instead, I have to hope I can code up a test that gives the exception,
and then drop a breakpoint on the try (or, if I've been silly and
failed to emite __FILE__ and __LINE__ information in my complaint,
on a number of the catch (...) statements), and then futz with the
debugger until I see the throw.
And then hope it isn't "catch (...) { throw SOME_CONSTANT; }" or
equivalent.
Tedious, boring, mind-numbing work.... just to get to the point where
you can *start* the debugging process.
> Not that I understand why anyone would *want* exceptions. Exceptions are a
> language design flaw.
For C++, that's a reasonable position.
--
C++ is a language design flaw.
Stewart Stremler
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg