AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

Asserts

Open jgonet opened this issue 7 months ago • 0 comments

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:

  1. 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.
  2. For hot paths, having a toggleable assert macro would be also nice. It also needs benchmarking, maybe asserts in term.h doesn't slow execution that much.
  3. I heard that there are plans for adding ASSUME macro. 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.

jgonet avatar Jun 16 '25 15:06 jgonet