SPACED, UNSPACED, and the FORM-ing of VOID

Historically in Rebol, the #[none] value would FORM and MOLD to appear as the WORD! none. This is still the case today in Red:

>> form #[none]
== "none"
>> mold #[none]
== "none"

One way of looking at this would be that as a none is a value a variable might wish to hold, that being able to show that is helpful for reflecting the state of a variable:

 >> x: none
 >> print ["The value of x is" x]
 The value of x is none

But many practical cases would be improved if it just disappeared, such as these:

>> print ["thing to include" if false ["thing to omit"]]
thing to include none

>> parentheses: false
>> rejoin [
        if parentheses ["("]
        "thing to maybe parenthesize"
        if parentheses [")"]
    ]
== "nonething to maybe parenthesizenone"

To say that finding a deep philosophy of PRINT has been difficult would be an understatement. Should it space or not...should the "#[none]" value be represented with an underscore for "blank", and print ["Then use that for spacing" _ x]. :-/ Several questions remain unresolved even now.

Yet ultimately the decision was to create two routines, SPACED and UNSPACED, which treat voids as the absence of anything to stringify. PRINT invokes SPACED by default if given a block, and if one wishes to get an unspaced print you simply say print unspaced [...].

The result has been a profound improvement. Says @ShixinZeng:

I love it. It's much easier to write than either true ["something"][""]

You too will love it. It's much better than REJOIN. You're going to use it again and again.

Feel free to add your testimonials here.

1 Like

I'll also mention that not only is print unspaced [...] more literate and comprehensible than print rejoin [...] from a terminology standpoint, the fact that UNSPACED always returns a string is important.

Note how the property of REJOIN adopting the type of its first element can cause unpredictable variations, that would throw off new users:

>> x: [some stuff]

>> print rejoin ["the data is" space x]
the data is some stuff

>> print rejoin [x space "is the data"]
*** Script Error: some has no value
*** Where: print