Talk:Assertions

From Rosetta Code
Revision as of 08:38, 26 October 2009 by rosettacode>Dmitry-kazakov (Behavior of assertions)

I propose adding to the task that examples shall state whether there is a compile- or run-time option to enable/disable assertions (as in C or Java) or not (as in Common Lisp or E). --Kevin Reid 03:07, 26 October 2009 (UTC)

Yes. A more general related issue is whether the assertion is a part of the program logic or not. Consider assertions raising exceptions. Let the program handle these exceptions and do something different than terminating or breaking into the debugger. This is a behavior, which will be lost when the assertion gets disabled. For example, a program may assert that the file end is not reached and exit the file reading loop when the assertion fails. Such programs are considered "wrong". But failed assertions have to behave in some way. Once they do (e.g. propagate an exception) that behavior can/must be exploited making the program broken, almost automatically. --Dmitry-kazakov 08:38, 26 October 2009 (UTC)