REBOL Technologies

Comments on: Lots of feedback on FORALL [Updated]

Carl Sassenrath, CTO
REBOL Technologies
1-Jun-2005 15:45 GMT

Article #0170
Main page || Index || Post Comments || Send feedback

We have received quite a bit of feedback from users regarding my prior article about the FORALL and FORSKIP functions. Opinions were evenly split between the "change it" and "don't change it" camps.

To help settle this issue, we've created a new test build of REBOL (View 1.2.116) that includes the modified versions of the FORALL and FORSKIP functions. You should try these out very soon (today if possible), and let us know what you think. If we do not hear a strong objection, these will become the new functions.

Here is a short example to help clarify:

items: system/locale/days
forall items [print items/1]

The items block is now reset to its original position:

probe items
["Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday"]

But, if you BREAK during the loop, the block will stay at the break position:

forall items [if find items/1 "Fri" [break]]
probe items
["Friday" "Saturday" "Sunday"]

And finally, if you begin the loop at an offset position (not the head), that's what will be reset to after the operation:

forall items [print items/1]
probe items
["Friday" "Saturday" "Sunday"]

There is just one other important case:

result: forall items [
    if find items/1 "Fri" [break/return true]
if result [print "Found it"]

Here the return value of the FORALL function indicates if the item was found or if the loop completed without it being found.

Important note:

In the example above, if no BREAK occurs, FORALL will return the result of the block. If BREAK/return, the value is that provided to the BREAK.

I would like to thank Gregg Iriwn and Ladislav Mecir for their help in developing, building, and testing this solution.

Post Comments

Post a Comment:

You can post a comment here. Keep it on-topic.


Blog id:



 Note: HTML tags allowed for: b i u li ol ul font p br pre tt blockquote

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 26-Nov-2014   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code