Open
Description
A for statement no checks whether the counter x
is between start
and end
. this is handy if you dont really know where you're counting up or down (we dont know if step is positive or negative).
FOR x := start TO end BY step DO
...
END_FOR
so we do a check like:
x >= start && x <= end || x >= end && x <= start
to accomodate for both situations (start < end
-> counting up or start > end
-> counting down)
if we know that we count up (or down) at compile time (e.g. if no step is provided, or it is a literal), we can skip several of the checks. when counting up, we only need to check against the x <= end
...