REBOL 3.0

Comments on: PARSE: last few changes are too disruptive

Carl Sassenrath, CTO
REBOL Technologies
14-Oct-2009 4:39 GMT

Article #0272
Main page || Index || Prior Article [0271] || Next Article [0273] || 14 Comments || Send feedback

The OS X version of R3 A89 would not boot. On closer inspection, there was an infinite loop in the CLEAN-PATH function that is called during the boot.

The problem was this line within the PARSE rules for CLEAN-PATH:

| copy f [to #"/" | to end]

If it had not been so fresh on my mind, I'm not so sure I would have noticed the problem. In that line the TO END is always TRUE. That creates two different behaviors from before:

  1. The SOME block which holds this rule is now an infinite loop.
  2. The COPY f always creates a string (it's never NONE).

It took me a minute to figure out the fix. It was to add:

end break

at the top of the SOME loop. Kind of ugly really.

This situation got me rethinking the definitions of ANY and SOME, especially in light of changes over the last few days.

The ANY and SOME keywords are provided as shortcuts for ease of use. They are for us normal coders who want "smart defaults".

It was a mistake to change ANY and SOME to ignore the state of the input series... instead, we should have left those alone, and added a new keyword for users who want a loop that is independent of the input series.

Now, we need a good name for it. ALWAYS, LOOP, FOREVER, suggestion?

14 Comments

Comments:

Peter Wood
14-Oct-2009 1:18:16
EVERY would go well with ANY and SOME.
Maxim Olivier-Adlhoch
14-Oct-2009 1:25:24
IMHO, the correct word would be 'CYCLE
-pekr-
14-Oct-2009 2:43:16
not sure about 'every, as it evokes 'foreach imo, not also sure about 'cycle, as it might evoke 'recycle :-)

First I liked 'always, 'loop is a classic, but 'forever imo describes it the best way - it loops forever, unless you break manually.

DideC
14-Oct-2009 4:07:23
+1 Forever
Brian Hawley
14-Oct-2009 4:56:02
I vote for FOREVER, with LOOP as my second choice. ALWAYS is ambiguous.
Ladislav
14-Oct-2009 8:19:38
If the safer any variant is kept (I prefer the variant #2 - stop when not advancing - in that case), then instead of the new, unsafe every (or any other word), we could just use the "unsafe" until and write:

until fail [b |]

, whis is exactly the "unsafe" variant of any.

Ladislav
14-Oct-2009 8:24:44
My prefered keyword is every. Please ignore the above (wrong) until example, until does not look like suitable for simulating that.
Ladislav
14-Oct-2009 9:16:08
It seems, that one of the simplest working simulations of every using until would be:

until fail [b | c: fail] | :c
Book Siberia
14-Oct-2009 12:54:22
Dare I mention

forever/ unless

:) [ "just kidding" ]

Book Siberia
14-Oct-2009 14:09:40
Dare I mention

forever/ unless

:) [ "just kidding" ]

RobertS
14-Oct-2009 16:14:33
I cannot get a89 to execute on my XP Sp3 box - not even redirecting a script and not even within cygwin - it just hangs without ever getting to a prompt.

Anyone else? Reverting to a88 and all's well ..

Carl Sassenrath
14-Oct-2009 17:04:37
Another choice is WHILE. It's actually quite close: while the block succeeds, repeat it.

RobertS: that's the PARSE bug we're fixing right now.

Book Siberia: I am glad you are kidding.

Ladislav: UNTIL is quite difficult to implement. We can discuss that.

-pekr-
14-Oct-2009 17:47:17
I don't have clear prefernce here, both LOOP and WHILE do it for me. Even LOOP loops forever, unless you break. Ah, I just used four keywords in last sentence :-)

It is not easy to use words we know from the REBOL context, and use them in another context (parse), as at first sight, we might try to map their meaning.

So - LOOP vs WHILE - each can be used, each has its own connotations ...

LOOP - sounds traditionally, so traditionally, that it might not nicely fit nice naming scheme as - ANY, EVERY, SOME, STAY (removed), THEN. But - most probably it is just me - I never user LOOP in REBOL, so ...

WHILE - sounds good too, I like it in conjunction to functions like UNLESS, UNTIL. The slight trouble is, that in REBOL level, it takes two arguments - WHILE true-condition do-code. But that aspect might be forgivable in parse context, right?

So, if we don't plan to use kind of: WHILE rule then-rule, then we can use WHILE, but if WHILE word might be usefull in future, let's use LOOP ...

I am not of much help here, am I? :-)

Ladislav
19-Oct-2009 5:25:53
I couldn't resist to look at the rule mentioned in this blog. The complete rule was:
some [
    "../" (++ cnt)
    | "./"
    | #"/" (
        if any [not file? file #"/" <> last out] [
            append out #"/"
        ]
    ) | copy f [to #"/" | to end] (
        either cnt > 0 [
            -- cnt
        ] [
            unless find ["" "." ".."] to-string f [
                append out f
            ]
        ]
    )
]

The reason, why this rule ended up as an infinite loop is explained in the blog. I figured, that the rule does not look as it should, though, and that is why it caused the infinite loop too. The fact is, that the

copy f [... | to end]
part is not what is intended, and the rule actually should have been as follows:

some [
    "../" (++ cnt)
    | "./"
    | #"/" (
        if any [not file? file #"/" <> last out] [
            append out #"/"
        ]
    ) | copy f [to #"/" | some skip] (
        either cnt > 0 [
            -- cnt
        ] [
            unless find ["." ".."] to-string f [
                append out f
            ]
        ]
    )
]

Note, that we do not have to handle the empty string in the paren, since it cannot be obtained.

At the same time the rule cannot cause an infinite loop.

Post a Comment:

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

Name:

Blog id:

R3-0272


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a 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.

REBOL 3.0
Updated 22-Sep-2017 - Edit - Copyright REBOL Technologies - REBOL.net