AtomVM
AtomVM copied to clipboard
Asserts
Currently, there's not a lot of asserts in the project, except for term.h.
term.h uses TERM_DEBUG_ASSERT to implement asserts. It's currently not defined, I suspect when changing code there, people define it temporarily.
Some thoughts:
- I really like using assets in cold paths like NIFs, they don't have much overhead and can save some debugging and adds a bit of clarity for invariants.
- For hot paths, having a toggleable assert macro would be also nice. It also needs benchmarking, maybe asserts in
term.hdoesn't slow execution that much. - I heard that there are plans for adding
ASSUMEmacro. I don't know any specifics, in other languages this typically refers to checking invariants that should stay in release builds.
I'm wondering if contributors have desire for having more asserts in the codebase.