Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: for bug?

From: rotenca:telvia:it at: 17-Jun-2002 16:47

Hi Joel,
> 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 i: start while [i <= end] [ do-body i if i >= end [break] i: i + bump ] ] This slows code a little, i admit.
> Consider the following: > > >> for i 2147483640 2147483647 1 [print i] > 2147483640 > 2147483641 > 2147483642 > 2147483643 > 2147483644 > 2147483645 > 2147483646 > 2147483647 > ** 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 low. --- Ciao Romano