Comments on: PARSE: which is proper COPY result?

Carl Sassenrath, CTO
REBOL Technologies
9-Oct-2009 4:30 GMT

Article #0264
Main page || Index || Prior Article [0263] || Next Article [0265] || 5 Comments || Send feedback

While looking over the new decode-url bug, the source of the problem comes from this small difference in parse:

>> chars: charset "abc"
>> parse "x" [copy s [some chars | none]]
>> s
== ""

before the rewrite, s was set to NONE. The question is, which result is correct?

This situation also exists for blocks:

>> parse [a] [copy b [some 'x | none]]
>> b
== []

The fact that both s and b have values is an indication that the rule succeeded. The prior parse behavior came from the fact that if the input did not advance, then the result was NONE.

We need to make a decision on this. The code change is minor, but we must weigh the issues of compatibility with correctness.



9-Oct-2009 4:17:57
I prefer the new behaviour. It looks more understandable than the previous one, exactly since the COPY result is related to the success of the rule, so it adheres to the principle of the least surprise.
9-Oct-2009 4:31:24
... and less error handling code is needed. 1+ for the new return type
Brian Hawley
9-Oct-2009 10:03
For years now we've had to workaround the old behavior in productions to get the new behavior. The old behavior was a frequent cause for frustrated questions in the help groups too. Keep the new behavior :)
Hostile Fork
9-Oct-2009 11:40:06
I think it is clear to anyone copying and pasting code snippets that R3 and R2 are not directly compatible.

Anyone making the switch will have to go over existing code with an eye toward a migration issues checklist. Parse is already on that list.

Which makes the choice in a matter like this obvious: correctness.

I will reiterate my proposal that "simple parse" be renamed (e.g. to lexify) in order to make parse *always* return either true or false, as well as to make sure all search hits on parse land people on interesting pages as opposed to trivial ones. People have a tough time getting new ideas in their head, and you make it harder when you say "parse is this mundane thing, but it's also this exciting thing"

Much more of a slam dunk when you can say "parse is amazing! always! it always returns either true or false, and it always takes a dialect!" The whole idea of formalized parsing is beyond the average programmer, and there's no sense making it trickier by conflating ideas into a single bizarro function.

Carl Sassenrath
9-Oct-2009 14:55:58
Ok, the new behavior stands. I'll fix DECODE-URL.

HF: That's a good point and the subject for a new blog.

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 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.

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