« first day (2229 days earlier)      last day (1551 days later) » 

10:09 AM
@RebolBot
x: 0
result: while [x < 2] [
    x: x + 1
    "something"
]
print result
 
; Brought to you by: try.rebol.nl
something
 
This concept of "returning the last body evaluation of the loop" seems to largely be a feature that is exposed just because it's a value that happens to be in the output cell already. The body has to be evaluated into some cell, and the output is available. So that's just what's there. But is this the most useful result from such a loop ?
In the case of LOOP-UNTIL (a.k.a. historical "UNTIL") I would say it is of demonstrable practical value to have the last body result be the return result. You also know something about that result--it is non-void and it is TRUE?
So no arguments there, that's good. But I question how good it is for WHILE. There's no guarantees about what the body produced, it may be void, it may be FALSE? or TRUE?. You can't casually splice a while loop in the midst of an any [... while [...] [...] ...] and have that be meaningful; 9 times out of 10 you aren't interested in the body result at all.
So I had the concept of saying that such loops would be TRUE by default, but void if the body never ran, and that BREAK would default to BLANK! but BREAK/WITH would allow any value but void. (Given that BREAK/WITH a void would revoke the /WITH, and revert to what BREAK does, that doesn't require any special error.)
So BREAK-ing a while in an ANY would "continue the ANY", and BREAK-ing a while in an ALL would "break the ALL". The loop itself never running would continue either, as the void result would opt out.
That strikes me as much more useful, and I'd actually use that. It would eliminate the need for the /? refinement. The last value of the WHILE body I have never used, but if the need ever came up I could write (while [...] [... result: ...] :result)
Hybrid proposal based on "principle of most information" would say the default evaluation would be to the last loop body value if it were TRUE?, and simply TRUE if it were otherwise (false, blank, void)
^-- opinions sought (@Brett, @rgchris, @MarkI, @rebolek, @ShixinZeng, anyone else who uses loops. :P)
 
 
4 hours later…
2:46 PM
macOS automated builds for master branch were not working since a few days, it is fixed now.
 
 
7 hours later…
10:12 PM
@HostileFork Hybrid preferable.
 

« first day (2229 days earlier)      last day (1551 days later) »