REBOL 3.0

PARSE: any, some, loop with break and reject

Carl Sassenrath, CTO
REBOL Technologies
14-Oct-2009 20:01 GMT

Article #0273
Main page || Index || Prior Article [0272] || Next Article [0274] || 8 Comments || Send feedback

Here's the implementation planned for A90:

 anyattempts rule until it fails or the input did not change. Always succeeds.
 somethe same as any except requires at least one match to succeed.
 whilethe same as any except does not care if the input changed. The while keyword is used for special cases where iterations may not modify the input position, but we want the loop to continue.
 breakbreaks out of any of the above loops, always indicating success.
 rejectbreaks out of any of the above loops, always indicating failure.

Note that both break and reject stop the loop iteration immediately. Any pending copy or set actions are not done.

BREAK or ACCEPT?

The one remaining issue might be: should we rename break to accept or just leave it as is?

The main reason to rename it is to better match reject.

The reason not to rename it is that people already know about break.

Updated

The while keyword is used instead of loop. The rationale is that a while loop continues while the condition is true. So, while is closer in meaning than loop.

8 Comments

REBOL 3.0
Updated 24-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net