Local is better then global!
This is one of our rules. But this rule is somehow in contradiction with the rule: "Explicit is better than implicit" when we are talking about _scan_ and _control variable_ iterator. In the next example variable i is explicit declared.
Plan: A
make i ∈ Z; -- local variable
scan [0..10] :> i do
** force next iteration
when i % 2 = 0 do
skip;
else
** write only odd numbers
write i;
write ',' if (i < 10);
done;
next;
print i; -- still available
The question for debate is: Should we implicit declare i using ∈ in the scan context ? Like:
Plan: B
```
scan i ∈ (0..10:2) do
** write only odd numbers
write i;
write ',' if (i < 10);
next;
print i; -- unavailable
```
Which one is better?
Posted Jun 4, 2019, 3:12 PM UTC · edited
21