Aussie AI
Next-Level Assertion Extensions
-
Book Excerpt from "Generative AI in C++"
-
by David Spuler, Ph.D.
Next-Level Assertion Extensions
Here are some final thoughts on how to further improve your assertions:
- Change any often-triggered assertions into proper error messages with fault tolerance. Users don't like seeing assertion messages. They're kinda like gibberish to ordinary mortals.
- Add extra context information in the assertion message (i.e. add an extra information string). This is much easier to read than a stringized expression, filename with line number, or multi-line stack trace.
- Add unique codes to assertion messages for increased supportability. Although, maybe not, because any assertion that's triggering often enough to need a code, probably shouldn't remain an assertion!
- Inlined assertion function?
Why use macros?
Maybe these assertions should instead be an
inline
function in modern C++? All I can say is that old habits die hard, and I still don't trust the optimizer to actually optimize much.
• Next: • Up: Table of Contents |
The new AI programming book by Aussie AI co-founders:
Get your copy from Amazon: Generative AI in C++ |