PARSE: do we need UNTIL?

Carl Sassenrath, CTO
REBOL Technologies
13-Oct-2009 23:09 GMT

Article #0271
Main page || Index || Prior Article [0270] || Next Article [0272] || 9 Comments || Send feedback

Ladislav has suggested UNTIL:

parse str [until a b]

This means: while rule a fails do rule b.

This is an iterative version of the common recursive pattern:

c: [a | b c]

which is used all over the place in language definition rules.

At first, I would ask is UNTIL really necessary?

Second, I would ask how difficult is it to write an iterative rule for it using the features already available?

And third, what's the precise definition of UNTIL (in terms of rules allowed with it.) For example, are these valid?

until not a b
until 3 a b
until set h 1 3 a b
until a 3 b
until a copy h b

Fourth, what happens if rule b fails? Does the UNTIL fail?

Unless these questions can be answered quite soon, and the definition be something easily implemented, it is not likely that UNTIL will be part of 3.0.


Updated 13-Jun-2024 - Edit - Copyright REBOL Technologies -