2.6. Built-in Functions¶
Builtin functions are function-like expressions that are available without any modules. They implement inherent mechanisms of the language, in available in the AST as separate expressions. They are different from standard functions (see built-in functions).
2.6.1. Invoke¶
-
invoke
(block_or_function, arguments) invoke
calls a block, lambda, or pointer to a function (block_or_function) with the provided list of arguments.
2.6.2. Misc¶
-
assert
(x, str)¶ assert
causes an application-defined assert if the x argument is false.assert
can and probably will be removed from release builds. That’s why it will not compile if the x argument has side effects (for example, calling a function with side effects).
-
verify
(x, str)¶ verify
causes an application-defined assert if the x argument is false. Theverify
check can be removed from release builds, but execution of the x argument stays. That’s why verify, unlikeassert
, can have side effects in evaluating x.
-
static_assert
(x, str)¶ static_assert
causes the compiler to stop compilation if the x argument is false. That’s why x has to be a compile-time known constant. ``static_assert``s are removed from compiled programs.
-
concept_assert
(x, str)¶ concept_assert
is similar tostatic_assert
, but errors will be reported one level above the assert. That way applications can report contract errors.
-
debug
(x, str)¶ debug
prints string str and the value of x (like print). However,debug
also returns the value of x, which makes it suitable for debugging expressions:let mad = debug(x, "x") * debug(y, "y") + debug(z, "z") // x*y + z