[REBOL] Re: for bug?
From: rotenca:telvia:it at: 17-Jun-2002 16:47
> The problem with post-condition tests is their inability to
> "do nothing gracefully". In the case
> >> for i 3 2 1 [print i]
> == none
> which can be understood as
> print each number i in the range [3 <= i <= 2] stepping by 1
> nothing should print, because the range is empty.
It seems to me that the solution is a pre-conditon test and a post-condition
test with something like:
myfor: func ['word start end bump body /local i do-body][
do-body: func reduce [[throw] word] body
while [i <= end] [
if i >= end [break]
i: i + bump
This slows code a little, i admit.
> Consider the following:
> >> for i 2147483640 2147483647 1 [print i]
> ** Math Error: Math or number overflow
> ** Where: for
> ** Near: start: start + bump
I think that an overflow error! is the right thing to do also with unsigned
byte (char). Because this is exactly what is happening with a char in 'for: it
can't add 1 to 255 without overflow.
I agree: the problem is also how Rebol handles limit values. Orthogonality is