Apostrophes have been on the rise purposefully in names also throws. Not only is there isn't
and didn't
coming very soon to wide use, but I do kind of like the mathematical convention of ticking apostrophes on the tail of things to make "derived" versions of them (f
, f'
, f''
)
block: [isn't "Hello"]
switch first block [
'isn't [print "This runs"]
]
foo': specialize 'f [arg1: 10]
foo'': specialize 'f' [arg2: 20]
action: get 'f''
2022 UPDATE: Terminal apostrophes in variable names is also a common practice now to indicate a variable holds a meta quantity.
Might There Be An Alternative Choice For QUOTED! ?
Something I haven't been able to shake since the beginning of seeing the usage of apostrophe for LIT-WORD! is that it is too slight for something as important as it is.
There's a big difference between foo
and 'foo
but it's rather hard to see. This is kind of slight:
code: '(
#foo [baz bar]
whole bunch of stuff ...
)
But What About... the Neglected Backslash?
Backslash is currently unused. We've thrown around ideas for backslash from time to time. It was the original expression barrier concept, before | took that over.
Despite its common uses for escaping in other languages and mediums, it's never come up as the idea for being the generic literal escape. But, it actually seems pretty well-suited to it.
Looking at some options with unused characters:
UPDATE 2022: Uses for @ and ^ are now more or less "set in stone" (to the extent anything in Ren-C ever is)
if word = \isn't [...]
if word = 'isn't [...]
if word = ^isn't [...]
if word = @isn't [...]
if string = \"something" [...]
if string = '"something" [...]
if string = ^"something" [...]
if string = @"something" [...]
>> compose [(1 + 2) \(1 + 2) \\(1 + 2)]
== [3 (1 + 2) \(1 + 2)]
block: [a b c]
switch block [
\[a b c] [print "literal match!"]
...
]
Benefits:
- Doubled-up usage can't be visually confused with another symbol (like how two apostrophes look like quotes, or an apostrophe and quotes can look like quotes and an apostrophe)
- It doesn't require shift to type on most keyboards (though a little bit of a pinky-reach)
- Known usage for escaping in other languages
(Note: The benefit of it being used for escaping in other mediums also makes it a bit of a drawback, as when you're typing in code in some text or markdown environment and use a backslash it can trip it up...because it thinks you're trying to escape. Of course you run into that problem with any code... like typing *
and having it think you're trying to bold something, etc. Still, backslashes can be one of the trickiest things to get these mediums to actually display how you want.)
Caret isn't bad-looking either. But the big problem with caret is that you don't want the escaping method used for weird characters in strings to interact with commonly-used characters in code. Because code is often carried in strings (or molded to it, etc.) It's best if caret occurrences are few and far-between, but literals would be a lot of places. You've got to diversify your escaping mechanisms, otherwise you have to escape your escapes more often.
Radical Brainstorm: Beginning And End For Quotes
The other thought I had when first questioning '
was what if double quotes weren't used for strings, but for quoting arbitrary material literally:
block: [isn't {Hello}]
switch first block [
"isn't" [print {This runs}]
]
It would look better when quoting SET-WORD!s as "foo:"
, and provide clearer and more visible delimiting on GROUP!s:
code: "(
#foo [baz bar]
whole bunch of stuff ...
)"
Because it would be part of a paired delimiter, you wouldn't have to worry about nested quoted material.
While this is sort of "interesting" it's completely incompatible. It makes you type two delimiters when a common case only required one. And from my experiments trying using only braced-strings to see if quotes could be freed up for something else, I found the braces were far too heavy when used for every string.
Plus the presence of two styles letting you conveniently have things like a string with a single brace "{"
.