Yes, I use asserts all the time, basically whenever I'm making an assumption that:
- Can be checked with a fairly simple predicate.
- Isn't obviously true simply from reading the nearby code.
However, for asserts that are likely to have a negligible impact on performance, I use the enforce
function in the D programming language standard library instead of assert
. This does basically the same thing as assert
except that it stays around in release mode. For more expensive assertions, I use assert
, which is stripped from release mode builds.