Thank you for taking time to do this; I agree completely with your rationale and approach.
As a general note on asserts, I'd like to remind people that an assert should only be used for a condition that is NEVER logically able to happen, regardless of the program's input. A failed assertion always indicates that there is a bug in the engine. (Not in the WML or other input). Also, it's okay for assert to be included in release builds, as long as the cost of the assert doesn't affect the performance of the build. We'd rather bugs be reported based on assertion failures rather than some weird abberant program behavior. I tend to think that WML_ASSERT should actually throw an exception if it fails, and this exception should unwind things to some high level function where the error is reported. The model we use for error handling is that errors internal to the engine (i.e. bugs) are handled by assertions. Errors external to the engine (i.e. bad input) are handled through exceptions. David Quoting Mark de Wever <[EMAIL PROTECTED]>: > Hi, > > At the moment we use wassert which is mainly a wrapper to assert. But it > has an option to be used for platforms which don't support assert. Since > we also have code which uses the normal asserts I assume the code for > wassert to be obsolete. If there are no objections I'll remove > wassert.hpp and wassert.cpp and convert the code to use assert instead > of wassert. > > Related to that we have quite some code that uses asserts on data > transferred from WML. For some reason our builds are compiled with > assertions still working, once we get a platform which doesn't we might > get some weird bug reports. I added WML_ASSERT [1] which can test a > condition but can also have a message to give hints to the user what > went wrong. When this assert is triggered it should be catch at game > level (or before) so we can show an error and go back to the > titlescreen. This avoids terminations due to asserts, which users see as > crashes. I'll look into converting the existing code to use this kind of > assert and also look at which asserts should be a runtime check. > > Regards, > > Mark de Wever aka Mordante/SkeletonCrew > > [1] https://mail.gna.org/public/wesnoth-commits/2007-12/msg00024.html > > _______________________________________________ > Wesnoth-dev mailing list > [email protected] > https://mail.gna.org/listinfo/wesnoth-dev > _______________________________________________ Wesnoth-dev mailing list [email protected] https://mail.gna.org/listinfo/wesnoth-dev
