Recently I discovered that Nim can insert assertions at the end of each loop, to ensure that the length of the seq is unchanged, so I decided to put a {.push assertions: off.} to the top of each loop. My question is, is there a simpiler way to do this, except by turning off assertions globally?
It also caused me to think about that, maybe we need some form of altnative seq, with unchangable length.
Iterate over the loop using indices instead of an iterator
But it'll then perform a bound check at the beginning of each loop, and a overflow check at each end, which is no more efficient than assertions, and still needed to be turned off.
Oh I see. Even if loop though items, boundary and overflow checks still exist.
But I still want alt seq with unchangable length. Arrays do have fixed length, but must be determined at compile-time.
But it'll then perform a bound check at the beginning of each loop, and a overflow check at each end, which is no more efficient than assertions, and still needed to be turned off.
Bound checking and most assertions are turned off in release mode
Not true, they are only turned off in danger mode. https://github.com/nim-lang/Nim/blob/devel/config/nim.cfg#L74
Maybe you can define your own iterator that does push checks: off for the element access.