Looping Assertions

2022-11-01 Thread Araq
Compile with `--assertions:off --overflowChecks:off`. The array bounds checks can sometimes be optimized out by the C(++) backend.

Looping Assertions

2022-11-01 Thread Hlaaftana
Not true, they are only turned off in danger mode. Maybe you can define your own iterator that does `push checks: off` for the element access.

Looping Assertions

2022-11-01 Thread haxscramper
> 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

Looping Assertions

2022-11-01 Thread haxscramper
> 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

Looping Assertions

2022-11-01 Thread haxscramper
Seq with unchangeable length can be implemented as `type FixedSeq[T] = distinct seq[T]` with only certain overloads allowed, like `[]=` but not `add`

Looping Assertions

2022-11-01 Thread sls1005
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.

Looping Assertions

2022-10-31 Thread sls1005
> 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.

Looping Assertions

2022-10-31 Thread sls1005
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 global

Looping Assertions

2022-10-31 Thread haxscramper
Iterate over the loop using indices instead of an iterator. And assertions are not "insered at the end of the loop" they are part of `items` iterator.