REBOL3 tracker
  0.9.12 beta
Ticket #0002217 User: anonymous

Project:

Previous Next
rss
TypeWish Statussubmitted Date3-May-2015 21:29
Versionr3 master CategoryUnspecified Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Make backslash the literal form of UNSET!...(bonus: good expression barrier)
Description SHORT AND SIMPLE:

Make \ the literal form of UNSET!. Hence as today:

>> type? second [a # b c]
== NONE!

There would be:

>> type? second [a \ b c]
== UNSET!

Literal forms for NONE! and UNSET! (and TRUE! and FALSE!) are necessary, and should be well-chosen.

Backslash is unpopular--and few people wish to see it as a word character or leaking much into general code. It is also notoriously difficult to use when writing in MarkDown or other places that use it for escaping when it is followed by data...and this case would be nearly always with a space on the left and right. (It does not create problems on StackOverflow chat this way, for instance.)

The primary user-facing application would be to serve as an efficient barrier for expression evaluation; hence a faster and prettier (IMO) solution to the original proposal of #2156.

LONG AND DRAWN-OUT:

The idea of being able to introduce a means of delimiting complete expressions has been sought after by several people (not just myself). It would offer a form of "punctuation" that had some kind of "teeth".

Today in Rebol if you write an expression like `any [a b c d e f g]` it can be difficult to tell how it groups. One way is to use line breaks:

any [
a b
c
d e f
g
]

This can hint to the reader where complete expressions are. But you're forced to break lines to do it, and in the end this doesn't have any "teeth" to catch you if you make a mistake.

Another option people might use would be parens:

any [(a b) (c) (d e f) (g)]

These will enforce that only complete expressions are evaluated, but to separate two independent groups requires 4 symbols. Beyond just the textual cost, parens represent series...which have overhead and separate garbage collection/etc. Note that even single items can't be non-parenthesized to get "safety":

any [(a b) c (d e f) g]

Consider if the author believed C to be arity zero, but unknowingly to them (or the reader/modifier) it was arity 2. You have to isolate everything.

Over time various workarounds and practices have emerged. @GrahamChiu suggested that if you wished to keep everything on the same line you double space the expression at the points you wanted to separate as independent clauses. Again, this lacks "teeth" and is solely a visual aid.

I made a suggestion of using an interstitial comma or period for the purpose. Hence you could write `any [a b . c . d e f . g]` and the period (or comma) would form some kind of "expression barrier type". In #2156 I proposed this, and @earl dug up that Carl suggested in a blog post that it might be possible to coax comma into this role...even making exceptions and allow you to write:

any [a b, c, d e f, g]

That wasn't as easy to try out as just using period. So I tried that for a while, with `.: does []` (so that it would evaluate to an UNSET!, as you can't put an unset in a variable and refer to it).

But I didn't like the appearance in practice...it was too visually slight for what it did. And I think Carl's proposal (or his "thinking-out-loud" as it were) of allowing commas to "tack on" to the tail of tokens and then be broken off to indicate separation is even more "anti-Rebol". I like that even less, even ignoring the technical problems with it.

Yet the need was still unfulfilled... so I tried vertical bar, which was a tremendous improvement over the period:

any [a b | c | d e f | g]

I was happy for a while. But in contemplating and discussing my contentment with it, I realized vertical bar was much too "owned" by people's ideas of how it would be used in PARSE...or as a word character in general. PARSE was not going to give up its usage of |, and it needed expression barriers as well.

So @Memophenon in chat made some other suggestions, including a "friendless" character...the backslash.

any [a b \ c \ d e f \ g]

Oddly enough, I found myself *preferring* the slant. It seemed to meet all the needs of really connecting the top of the block with the bottom that vertical bar had, while "standing out" from 1 or lowercase L or capital I. Consider also that people weren't going to be giving up | as a word character, so a| and || and |> were going to be around too.

When the efficiency benefit of just being able to scoot past an UNSET! with no function call was considered, as well as the need for literal UNSET!, it came to seem the leading option.

1. Not just an expression barrier, but fulfills a need for literal UNSET!
2. Very efficient implementation of an expression barrier that blocks most cases (QUOTE-like things can pick up the unset as a parameter, if they accept UNSET!)
3. Doesn't compete with PARSE, and as a literal form can actually drive dialect-independent adoption vs. a keyword
4. Limits the spread of \ in the Rebol language on the whole... this really is suggesting that \ would ONLY be a literal unset and nothing more.
5. People who are happy without any kind of expression barrier today don't need to use it and don't need to see \ ever in their Rebol code
Example code

			

Assigned ton/a Fixed in- Last Update3-May-2015 21:32


Comments

Date User Field Action Change
3-May-2015 21:32 Fork Description Modified -
3-May-2015 21:29 Fork Ticket Added -