3 ms·
> x = (x + 2step) % width Hmm. now. Is operator precedence not an instance of hidden flow control? You need to know that 2step is done before adding x. x =
by benj111 4mo ago
> x = (x + 2step) % width
Hmm. now. Is operator precedence not an instance of hidden flow control?
You need to know that 2step is done before adding x.
x = (x + (2step)) % width
Or
x = ( 2step + x) % width
Should be preferred?
Personally I try to bracket all things like this, so that it isn't hidden.
- hmry 4mo agoYes it is control flow, but IMO it's not hidden. It's true that you need to learn that * happens before + (which usually happens in school), but I don't see how that's any different from needing to learn that `and` short-circuits, or that `if` only evaluates its body if the condition is true. Compare to what people usually call hidden control flow (exceptions, RAII, ...) where you don't know which parts of the code will run unless you read the definitions of the classes and bodies of the functions you use. The syntax at the call site is not enough to tell.