[REBOL] Re: parse question
From: gjones05:mail:orion at: 27-Jun-2001 5:52
Hi, Graham, Brett, Joel,
I don't seem to be able to muster the skills to articulate an argument one way
or the other, which is just as well, because you would present a formidable
opponents. :-)
So, when I don't feel up to a good argument, I simply present a different way of
thinking about the "problems" at hand and will leave to each individual user
whether the approach is useful.
>From "Graham Chiu"
...
> parse {a="b"} [ thru {a="} copy test to {"} ]
... and ...
> parse {a=""} [ thru {a="} copy test to {"} ]
Pardon me if I am not using the terminology correctly, but to most simply
coerce
the result to a specific type, here was how I saw the problem:
parse to-block {a="b"} ['a= set t string! to end] ; == true
t ; == "b"
parse to-block {a=""} ['a= set t string! to end] ; == true
t ; == ""
From: "Joel Neely"
...
> Any time you wish to build a new string from the parsed
> substrings, or print their content, you have a problem with
> NONE! instead of an empty string. For example, given:
...
I understand that your example was presented as a piece of an argument meant to
demonstrate a concrete side effect of the behavior in question. Here was how I
saw the problem:
addr1: "John Doe/123 Lonely St/Suite 16/Los Angeles/CA/90210"
addr2: "Joe Doaks/321 Hilltop Ln//Green Mtn/MA/02187"
print-address-label: function [
s [string!]
][
addr-name addr-line1 addr-line2
addr-city addr-state addr-ZIP
][
foreach [addr-name addr-line1 addr-line2
addr-city addr-state addr-zip] parse/all s "/" [
print [
addr-name newline
addr-line1 newline
addr-line2 newline
addr-city addr-state addr-ZIP newline
]
]
]
>> print-address-label addr1
John Doe
123 Lonely St
Suite 16
Los Angeles CA 90210
>> print-address-label addr2
Joe Doaks
321 Hilltop Ln
Green Mtn MA 02187
I guess a "blank" line is better than a "none" line for this trivial
("no-additional-logic-added") example.
Remember, Joel, (et al,) "It's turtles all the way down!"
(I had to look that one up, BTW. If I had ever heard it before, I had certainly
forgotten it. :-)
--Scott Jones