[REBOL] Re: coding the closing parentheses correctly
From: moliad::gmail::com at: 1-May-2008 16:33
note that in my last example, I tried something different and it worked.
instead of calling parse recursively, I just dynamically set the
entity count within the rule and let parse's internal recursivity do
the rest. By calling the entity rule within the entity rule, parse
effectively continues looking for an entity then and there.
I don't know why I didn't do this in the first example.
this, is the correct way of using parse. The reason is simple, its faster.
Care must be taken though, because parse doesn't reallocate variables
or push them to a stack when using recursive rules. You must do so
yourself, when its needed, by adding a bit of code to the start and
end of rules. This is usually necessary when building data trees made
up of blocks for example, where every layer, must push the "current"
block to a stack, allocate a new one and use this new one as the
current block for children (the recursive rule) at that point. when
children return, you pop the block and continue using "your" current
block. this said, its advanced usage and seldom needed.
other ways to build data trees, are simpler, like in your example,
where we could have replaced the tuples with a set of parenthesis "(
)" forego of the colons "," and then used load on the string.
giving us a native rebol block with block! word! and paren! within.
On Thu, May 1, 2008 at 4:06 PM, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote: