A loop body for visiting just the set bits, used as for: only_set bits; it is true and it_index the position.
bits := make_bit_array(8);
bits[1] = true;
bits[6] = true;
positions: [..] int;
for: only_set bits array_add(*positions, it_index);
assert(positions.count == 2 && positions[1] == 6);
array_free(positions);
deinit(*bits);