REBOL 3.0

PARSE: what is default value for SET?

Carl Sassenrath, CTO
REBOL Technologies
25-Sep-2009 19:01 GMT

Article #0252
Main page || Index || Prior Article [0251] || Next Article [0253] || 5 Comments || Send feedback

For A84... I'd like to be sure we define the default value for SET of variables.

Currently the rule is: a variable will be SET only if its rule is successful. Otherwise, its value remains unmodified.

Example:

n: "y"
parse "a" [set n "x"]
?? n
"y"

The advantage is that you can setup the default easily.

The alternative is:

n: "y"
parse "a" [set n "x"]
?? n
none

I expect some of you have strong opinions one way or the other?

A possible solution is to provide a way to preset the variable within the parse rule (without a paren expression.)

BTW, this applies to COPY as well.

5 Comments

REBOL 3.0
Updated 25-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net