flint icon indicating copy to clipboard operation
flint copied to clipboard

Add a ``FLINT_ASSERT_ALWAYS`` macro

Open fredrik-johansson opened this issue 1 month ago • 2 comments

Idea: have an assert statement that is executed regardless of --enable-assert.

Whereas FLINT_ASSERT can do checks that are expensive to compute and thus needs to be disabled by default, FLINT_ASSERT_ALWAYS would be used for strategically placed inexpensive checks, i.e. as a shorthand for the current idiom if (!cond) flint_throw(...).

This would also be useful during development as a way to test individual FLINT_ASSERT macros without having to reconfigure FLINT with --enable-assert, by temporarily changing them to FLINT_ASSERT_ALWAYS.

fredrik-johansson avatar Nov 06 '25 13:11 fredrik-johansson

I'd rather name is something else, like CHECK, where the lack of prefix FLINT is due to it being internal only which saves some space on each line as well.

albinahlback avatar Nov 06 '25 14:11 albinahlback

You could also have asserts with different levels. ASSERT, ASSERT1, etc.. Ordered from cheap/important to expensive/stringent

edgarcosta avatar Nov 06 '25 19:11 edgarcosta