----boundary-LibPST-iamunique-730103625_-_-
Content-type: text/plain
The language report says:
9.8 For Statements
A for statement specifies the repeated execution of a statement sequence
while a progression of values is assigned to an integer variable called
the control variable of the for statement.
ForStatement FOR ident ":=" Expression TO Expression [BY ConstExpression]
DO StatementSequence END.
The statement
FOR v := beg TO end BY step DO statements END
is equivalent to
temp := end; v := beg;
IF step > 0 THEN
WHILE v <= temp DO statements; INC(v, step) END
ELSE
WHILE v >= temp DO statements; INC(v, step) END
END
temp has the same type as v. step must be a nonzero constant expression.
If step is not specified, it is assumed to be 1.
So by the way of implementation
FOR Index := MIN(BYTE) TO MAX(BYTE) - 1 DO
Out.Int(Index, 5);
END;
runs from index = -128 through index = +126 then finishes, whereas
FOR index := MIN(BYTE) TO MAX(BYTE) DO
Out.Int(Index, 5);
END;
when reaching index = +127 as on the next step index is increased to
MAX(BYTE) + 1 resulting in index = -128 thus starting the next loop.
This is in accordance with the language report but whether it was a good
idea to implement the FOR loop this way is another question.
H. v. Lavergne
On Thu, 22 Jun 2006 01:20:31 +0200, Rex Couture <rex{([at]})nowhere.xy
wrote:
> At 10:23 AM 6/21/2006, Treutwein Bernhard wrote:
>> Beware also that the following loops for ever:
>>
>> VAR
>> b : BYTE;
>> FOR b := 0 TO MAX(BYTE) DO
>
> This seems to me like an error in the language specification,
> but in any case it can be trapped by integer overflow checking, which
> can be implemented with compiler option '+'.
>
> Rex Couture
>
> --- BlackBox
> --- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy>
>
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-730103625_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1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