On 2011-01-06 06:45:41 -0500, Lutger Blijdestijn <[email protected]> said:

As you said, it is all about the error messages, not replacing assert perse.
So this comparison would be more fair, using the syntax suggested by Andrei:

assertPred!">"(a, b);

vs

assert(a > b, format("a > b failed: [%s] is not > [%s]", a, b) );

If you really want the error message, regular asserts are a bit uglier and
duplicate code.

The whole point of my proposal is to make the regular asserts print a message similar to yours *by default*, when you don't specify any message. This is possible because assert is not a function, it's a language construct handled by the compiler. The compiler has access to the whole expression tree, and it can rewrite the code to store intermediate results in variables it can later give to the assertion handler in case of failure.


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to