One big and unanswered question has been regarding the conversion of things to strings. I think that SPACED has come along as a pretty good name for what was "reform", and as a specialization of DELIMIT which also has UNSPACED for much of what was REJOIN, that territory is pretty well covered these days. They handle nulls and blanks nicely and are good words for what they do.
But though I haven't said it in a while, I used to mention a few times a week that I never liked the term MOLD. (Supposedly it originated from when Rebol was going to be called "Clay" and so you wold "mold" your output, but it's an eyesore and makes people think they're looking at moldy old code.)
And TO STRING! historically has been pretty bananas:
In Rebol2 and Red:
>> to string! quote foo:
== "foo"
>> to string! #foo
== "foo"
>> to string! <foo>
== "foo" ;-- well, at least it's consistent...
>> to string! [foo: #foo <foo>]
== "foofoo<foo>" ;-- oh, no, of course it isn't
In R3-Alpha:
>> to string! quote foo:
== "foo:"
>> to string! #foo
== "#foo"
>> to string! <foo>
== "foo" ;-- seems to break the pattern?
>> to string! [foo: #foo <foo>]
== "foo:#foo<foo>" ;-- errr...
With the advent of ANY-STRING! unification I believe we have an option which may cut through yet another design epic. Here it is:
Proposal: TO TEXT! for mold(-ish), AS TEXT! for (copyable) spelling
Ren-C has AS. It aliases types without making a copy. For instance:
>> block: copy [1 2 3]
== [1 2 3]
>> group: as group! block
== (1 2 3)
>> append group [4 5 6]
== (1 2 3 4 5 6)
>> block
== [1 2 3 4 5 6]
It is related to the function of AS-STRING and AS-BINARY in Rebol2, which could be used to view a byte sequence through the lens of being a STRING! or being a BINARY!, depending on which you needed. When the internal string format got complicated with unicode there couldn't be a guarantee of the byte format underlying, so it was removed.
But Ren-C is going to let you AS any string types between each other (including words). It will even be bringing back AS BINARY! on ANY-STRING. (In the UTF-8 Everywhere branch, the idea is to keep aliased series marked as having to stay valid as UTF-8. You'd get errors if you tried to put a bad byte sequence into a BINARY! which was elsewhere UTF8.)
So if all ANY-STRING! types can be aliased between each other, including words, why not use that for getting the spelling? It might be read-only, but you can copy it if you need to.
>> as text! quote foo:
== "foo"
>> as text! #foo
== "foo"
>> as text! <foo>
== "foo"
You can switch any string type over to any other:
>> as tag! #foo
== <foo>
It lets you make the copying decision--often you probably don't need it. And it's really only two more characters than today's copying "spelling of" operation, on the off chance you need to copy:
copy as text! x
spelling-of x
So with TO freed up, the concept is that the TO-TEXT conversions can act MOLD-like, and giving you whatever delimiters you "expect" to see:
>> to text! quote #foo
== "#foo"
>> to text! quote <foo>
== "<foo>"
Since TO makes copies, it's a good fit. Those delimiters/sigils need to actually be in there, visited by series traversals.
It may not be exactly MOLD, the needs for TO TEXT! of a CHAR! might not want to put the delimiters on. Maybe feeding it a BLOCK! would be invalid, even, just because there's so many potential ways to make strings out of blocks (evaluative, unevaluative, spaced, unspaced, with brackets, without brackets...)
But it would be moldish-enough that you would get the delimiters on your strings:
>> to text! "foo"
== {"foo"}
I guess the same would be true for the other ANY-STRING!s.
>> to tag! #foo
== <#foo>
>> to issue! <foo>
== #<foo> ;-- or however this construction-syntax-es
It raises more questions for what things like blocks should do, though:
>> to tag! [a b c]
== <[a b c]> ;-- hmmm.
How would AS EMAIL! (AS IDENTITY!) work?
I've spoken recently about the importance of being able to be able to "namespace" things by their string type. e.g. if you have an ACTION! defined via FUNCTION in TLS named CLIENT-HELLO, but also want to talk about the CLIENT-HELLO being a state you are in, why use a WORD! both times?
instructions: [... client-hello ...]
...
parse instructions [
some [... 'client-hello (client-hello arg1 arg2...) ...]
]
It's lame to have to come up with new words each time you want to talk about a different aspect of things, or put things in namespaces. Why not use a different datatype?
instructions: [... <client-hello> ...]
...
parse instructions [
some [... <client-hello> (client-hello arg1 arg2...) ...]
]
It makes it easier to keep track of things. And being able to flip easily back and forth with AS...especially when it doesn't mean you're making series copies each time...is useful.
But here's a puzzle. That means you want this:
>> as tag! @foo
== <foo>
>> as identity! quote foo:
== @foo
But if foo@bar for EMAIL! and @foo are the same data type (as Red has made them), what does the AS conversion mean there? The sigil is not always at the beginning.
Here's an idea: we could say that a leading @ is just the "construction syntax" for an email/identity that doesn't carry an internal sigil:
>> id: copy f@oo
>> length of id
== 4
>> take next id
== #"@"
>> id
== @foo
>> length of id
== 3
>> first id
#"f"
Then you'd wind up with:
>> as tag! @foo
== <foo>
>> as tag f@oo
== <f@oo>
Slightly confusing, but at least it's explainable. And I think it points to an answer for what would happen with URL! and such, too. If you say as word! http://example.com
you'll get a word with a colon in its spelling, which will require some kind of construction syntax to show you it's not an ordinary loadable word.
Something would have to be done for series with @ in the first position, and I guess it's just one of those things that would send it into construction syntax rendering. Also rendering when you're not at the head. I guess the question is if something can be done that's sane enough to work for most purposes--when you allow delimiters/sigils in the material itself it will cause problems (spaces in words, colons in set-words, etc.) but I do think these things have to be legal...and escaped in rendering somehow.