Why Parentheses As Default COMPOSE Escape?

Conventional wisdom for interpolation or templating would be to use something fairly uncommon, so as not to be likely to be confused with the content.

Yet Ren-C (and Red) use parentheses as a default:

red>> as url! #rejoin "http://(site)/(resource)?param=(date as "yyyy")"
== http://example.com/whatever.html?param=1998

ren-c>> compose http://(site)/(resource)?param=(date as "yyyy")
== http://example.com/whatever.html?param=1998

Why isn't something more uncommon used as the default, like {{}}

1 Like

You can see Red having some of this debate in REP 112.

Ren-C's concept is to make it easy to customize, which is why there is COMPOSE2... the arity-2 compose, which takes a pattern:

>> num: 1000

>> compose2 '{{}} "(Hello) {{num + 20}} {World}"
== "(Hello) 1020 {World}"

Since you're able to customize it easily, I think that the most potential is had by capitalizing on a short default... which would lead to picking [] or {} or ().

Of these three, I think () is the most compelling:

  • It is consistent with historical COMPOSE of lists, where groups were the composed tihng.

  • Strings are frequently bracketed, e.g. --[...]--, so the parentheses stand out better.

  • Parentheses are the most "malleable" in the sense of "likely to vaporize", e.g.they are evaluated where blocks are not

It's a bold choice to use plain old parentheses, but it feels like it's shaping up as being a clear winner as a default.