From: Erich H. <er...@gm...> - 2005-04-01 09:29:12
|
Hey everyone, I'm in process of cranking out a crappy gaim plugin, but I am hoping to start working on SDLmm really soon. I know you are eager to see any work at all, since it's been 4 years since the last commit :P This post is mainly to put things on the table for discussion. Now David has said that he has specifically left exceptions out of the library... I understand that a project goal is to stay as close to SDL as possible, which means, of course, using return values for error checking. As much as I think this goal makes it easier on the programmer used to writing in SDL, I think that this attitude inherently means that some of the advantages of C++ are going to be lost (exception handling would be one, however small). I'm of the opinion that, with some degree of restraint, perhaps this goal should be stretched a bit to allow for further development / improvement and not just a stagnant project. David had already outlined his intention of adding "additional features" to SDLmm, such as the sprite class, but I wonder if this attitude can't be applied to the current source. Anyway, here's my case for exception handling: 1) Exceptions offer a consistent way of handling errors. We know that if an error occurs within the library, an exception will be thrown. No need to check error values, check global error variables, pass references or pointers to objects containing this type of information, etc... 2) Exceptions reduce the amount of code the user of the library has to write. Instead of having something like: if (SDL_CreateSurface(...) == -1) { /* error handling code */ } and then having to rewrite the same construct again each time we call a function, we need only put the body of main inside a try block, and we can write code without having to _worry_ about error handling. Motto: "less code? yayyy!" 3) Exceptions can hold additional information about the error, and not just an error code or something retrieved from a global variable. I know this is an advantage, somehow... :) There's a good discussion about exceptions on this page, if you're interested: http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=77463 Exceptions aside, before I actually DO anything, I want to read through the code thoroughly, and alongside reading, fixing it up a bit ... is there any coding convention being used for the project right now? Anyway, I'd like very much to hear peoples' feedback about exception handling. Any additional concerns / requests / comments about the library, or what could be done better would make my job a lot easier. Thanks all, Erich Herz |