Hello Rebols:
A unique and very valuable feature of rebol is that control loops
*can* have return values. But consistancy in that matter is very
important and I'm finding that control loops don't *always* return
values if empty data sets are being processed.
Here's some examples which illustrates what can happen with such
inconsistancies:
t: foreach item [][item] ;; empty data argument
== none ;; that's a good thing. It would be even better
;; If I cound set a default return value
;; Now let's try 'loop
>> i: 1
== 1
>> t: loop 6[i: i + 1]
== 7
>> t
== 7 ;; okay, we got a return value, the last block evaluated
;; now let's suppose we use a 0 as 'loop's 'count argument
>> t: loop 0[i: i + 1]
** Script Error: t needs a value
** Near: t: loop 0 [i: i + 1]
Applying 'repeat to an empty series gives the same.
>> t: repeat ch ""[ch]
** Script Error: t needs a value
** Near: t: repeat ch "" [ch]
;; and 'repeat operating on a non-empty series:
>> t: repeat ch "ab"[ch]
== #"b"
>> t
== #"b"
;; inconsistent!
;; Now I'm going to be a bit of a curmudgeon here:
I do *not* believe it is good programming style to write a piece of
code (a subroutine in this case) that might return a value in one
case and not return a value in another case. I would strongly
advocate that this is an inconsistency that should be corrected.
IOWS: Either *always* no return values (as in 'print) or *always*
a return value (as in 'foreach)
I'd welcome other comments and observations on this matter. Maybe
I've completely missed something here.
MTCW
Tim
--
Tim Johnson <[EMAIL PROTECTED]>
http://www.alaska-internet-solutions.com
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.