Skip to content
Sword

Build modes

Bounds checks and overflow checks cost something, and the cost lands in the loop you care about most. Rather than deciding for the whole language, the mode decides per build:

Terminal window
shield program.sword --mode=debug # checks, no optimisation
shield program.sword --mode=safe # checks, optimised (the default)
shield program.sword --mode=fast # no checks
shield program.sword --mode=small # no checks, optimised for size

+%, -% and *% wrap on overflow and are never checked, in any mode. That is how you ask for wrapping on purpose, in a hash or a PRNG.

The difference shows up in the generated code: a summing loop stays scalar in safe, because the bounds check blocks it, and vectorises in fast. Same source, no annotations.