slang-users mailing list

[2008 Date Index] [2008 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Support for assertions?


Hi John,

do you plan to add support for assertion? I would like to write something
like assert(a == 4) and if it is false I want to get an AssertError with
the message “Assertion failed: a == 4”—or something this way.

I can't solve it easily with a function, because a function gets the
value of “a == 4” and not the expression. Using eval in the assert
function might not work, because a might be a local variable in the
calling function.

It would also be nice, if assert() has a second argument like throw to
give a better message for the AssertionError.

I can't estimate the ressource usage of such a function. Maybe it would
be useful to globally or locally enable or disable this function. While
developping I can enable assert and catch such errors, but for production
I can disable it and S‐Lang skips these commands.

What do you think, John?

Bye, Jörg.
-- 
Der Pessimist ist jemand, der vorzeitig die Wahrheit erzählt.
    	      	  	      		    	(Cyrano de Bergerac)



[2008 date index] [2008 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]