FluffyMcDeath wrote:
That's mighty pretty, Karlos, but I must quibble.
in:
if (thing) delete thing;
The test is redundant (delete NULL is safe).
if(!thing)
{
errorPopUpThingy("failed to alloc thing");
}
won't ever happen unless you use operator new(no_throw)
else new throws bad_alloc which you'll need to catch.
@Fluffy
You are absolutely correct about the no_throw, but I'm afraid you are assuming too much.
-edit-
Is it me, or does the above sound like it should have been wrapped in a sort of typical "James Bond villian" tag? :-)
-/edit-
Part of the reason the framework itself isn't pulbic yet is that it was written in that 'less than stellar c++' compiler, StormC.
Exceptions are not used by any of the components because I discovered early on that the exception mechanism in storm is
broken.
Its fine in single thread programs, but the framework defines a Threadable service class (kind of like a fusion of java Thread and java Runnable interface) that allows the class inhertiting the service to have its own internal thread of execution.
I discovered that in multithreaded code, the thread which throws an exception is hardly ever the one to catch it. That is, StrormC's implememntation doesn't do the book keeping.
StormC, even with exceptions enabled doesn't support new(no_throw) in any case, nor does it safely check the null pointer case for delete.
Basically any oddities you see are all down to the fact that I started in StormC++ which was a mistake.
The whole framework code will be moved to gcc which will hopefully not be too much of a problem since I don't use any storm dependent features (other than the ide). Some asm code exists in places (optimised versions of various methods).
Post gcc plans are to use proper exception based error handling (to replace the existing return value model) and probably some namespace resolution for libraries.
First things first, the code will be ported as is. Then exception handling introduced to replace the existing error returns (in places where a genuine error exists, rather than something better represented by a bool return etc.).
The gcc port will also make the cross platform coding a lot easier. Currently the windohs version is maintained in open watcom....