[REBOL] Re: parse question
From: ingo:2b1 at: 3-Jul-2001 12:38
Hi Robert,
Once upon a time Robert M. Muench spoketh thus:
> > -----Original Message-----
> > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
> > Graham Chiu
> > Subject: [REBOL] parse question
>
> > If parse always returns a string
> > eg: parse {a="b"} [ thru {a="} copy test to {"} ]
> > and 'test is now a string containing "b"
> >
> > shouldn't
> > parse {a=""} [ thru {a="} copy test to {"} ]
> > 'test now be an empty string rather than type none! ?
>
> Hi, I see the whole string "" as the definition for the empty string and there
> is nothing between " and ", therefore the none! return value is OK as you read
> thru the first " and up-to the next ". Robert
We might discuss the "validity" of this approach in length, but from
a practical viewpoint returning "" instead of none is much preferrable.
Returning none:
- If it doesn't matter to you, wether the string is empty or not,
you have to manually check all values, and change them to ""
- if it matters you may check for none? values
Returning "":
- If it doesn't matter to you, wether the string is empty or not,
you don't have to do any thing
- if it matters you may check for empty? values
=> all in all returning empty strings requires less programming efforts
kind regards,
Ingo