11.9. Assert once

The ASSERT_ONCE module provides the assert_once macro — an assertion that triggers only on its first failure. Subsequent failures at the same location are silently ignored, preventing assertion storms in loops or frequently called code.

All functions and symbols are in “assert_once” module, use require to get access to it.

require daslib/assert_once

11.9.1. Function annotations

assert_once::AssertOnceMacro

This macro convert assert_once(expr,message) to the following code:

var __assert_once_I = true  // this is a global variable
if __assert_once_I && !expr
    __assert_once_I = false
    assert(false,message)

11.9.2. Assertion

assert_once::assert_once(expr: bool; message: string = "")

Same as assert, only the check will be not be repeated after the assertion failed the first time.

Arguments
  • expr : bool

  • message : string