C. Hotchkiss wrote: > The fact that the program exits gracefully as opposed to crashing with > a null de-reference helps considerably. The former says something > unacceptable or unhandled occurred. In this case, if we could turn on > a parser log it could do a lot in pinpointing XML problems. > > Crashing, especially from de-referencing null pointers is usually > associated with bad code.
I'm aware of that. What folks don't seem to grok is that YASim is still very new. Of all the problems I've had inside the parser, only a minority of them have been due to syntax errors in the XML. The majority have been due to parser bugs, and the crash is *helpful* in these situations. Think of the *(int*)0=0 statement as a quirky form of an assertion. It works everywhere, on all platforms, and does the right thing. Much better and more portable than assert.h, frankly. The assert macro doesn't always halt the debugger or give you a core file. :) > Should we add good exception handling in the future, then throwing > and catching exceptions would make for a more robust way of dealing > with a lot of problems. And, it would probably be more informative. I certainly wouldn't argue. Although I'm really no great fan of C++ exceptions. In Java, which does them right, you can be guaranteed that your exception will be caught -- exceptions are part of the type signature of a method. In C++, making exceptions work requires a *lot* of coordination between the catcher and all the possible throwers. If you want a piece of information in a programmatic way, you need to make sure that all the throwers throw the right type. In practice, it seems that all anyone ever throws are strings, which aren't very useful except as debug messages on the screen. And you really don't get much for your effort. The data that you get with the exception is only what the thrower thought to include. And the (IMHO) most important part, the stack trace, isn't available at all! This is why I prefer the crashing idiom -- a crash gives you a stack trace. :) Andy -- Andrew J. Ross NextBus Information Systems Senior Software Engineer Emeryville, CA [EMAIL PROTECTED] http://www.nextbus.com "Men go crazy in conflagrations. They only get better one by one." - Sting (misquoted) _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel
