REBOL3 tracker
  0.9.12 beta
Ticket #0002203 User: anonymous

Project:

Previous Next
rss
TypeWish Statussubmitted Date13-Mar-2015 07:42
Versionr3 master CategoryUnspecified Submitted byabolka
PlatformAll Severityminor Prioritynormal

Summary Replace CR/LF/SP with words corresponding to the escaped characters
Description This proposal requires the escape syntax for words as suggested in #2195 as a prerequisite. This is a proposal by @HostileFork originally combined with #2195.

Once we have escaping in ANY-WORD! types, combine this with something suggested by @MarkI in chat:

http://chat.stackoverflow.com/transcript/message/21807451#21807451

This combination addressing something that has historically annoyed me...namely the abbreviations SP, CR, and LF. Yet for keeping print specs short enough to fit on a line they seemed impossible to get rid of without a sacrifice.

But now imagine this (again, #2195 required):

>> ^_: space
>> ^/: newline
>> ^-: tab
>> ^M: carriage-return

With these natural looking shorthands being actually defined to their counterparts, we can write things like this. (Here, you may model PRINT/ONLY X as PRIN REJOIN X, which is good enough for this case...)

>> x: {FIRST}
>> y: {SECOND}
>> z: {THIRD}
>> print/only [x ^_ y ^/ z]
FIRST SECOND
THIRD

That's more clear and readable than `print [x sp y lf z]` while being the same number of characters. And it's not the word-wrap-breaking debacle of `print [x space y newline z]` which was simply too long. Those two are arduous even in this small example; they only get worse in real-world cases.

It kills several birds with a few stones. Of course, the user could redefine these:

>> ^_: {foo}
>> ^/: {bar}
>> print/only [x ^_ y ^/ z]
FIRSTfooSECONDbarTHIRD

They're really just words. And you could print them, if quoted, and get them to print as words would. However, they would mold escaped.

>> print quote ^/

>> print mold quote ^/
^/

These would eliminate the need for CR, LF, and SP. And CRLF which currently exists and is terrible:

>> crlf
== "^M^/"

If you want that, for instance in a PRINT, you would just say:

>> print/only [{Line One} ^M ^/ {Line Two} ^M ^/]
Example code

			

Assigned ton/a Fixed in- Last Update13-Mar-2015 12:23


Comments
(0004605)
MarkI
13-Mar-2015 09:36

Unfortunately ^/ is not a word. If you want slashes in words, I'd say that's another ticket.
There's already ^J as a synonym for ^/ in strings; I'd use ^| as well if I could; both are words.

[I have something else in mind for ^/ ... but I'm only saying that because I'm in the Description; if that gets erased then I'll remove this.]


(0004606)
abolka
13-Mar-2015 09:57

_With_ #2195, ^/ would be a word. It would be a word with a spelling equal to "^(0A)".

It's nice that even without #2195, all but one of the above suggestions would be technically possible. _With_ #2195, they have an additional twist, though, which @HostileFork already briefly touches in his write-up: as PRINTing words prints out uses their spelling, `prin ^/` with #2195 would print out a newline, whereas without #2195 it would "just" print out "^/". Not at all important, in my opinion, but cute nevertheless.
(0004608)
MarkI
13-Mar-2015 10:25

There are barriers to using delimiters [](){}";/ as escape characters, is all I'm saying. Is there no other choice?
(0004609)
fork
13-Mar-2015 12:23

This proposal has suggested a possibility of escaping "that which didn't need to be escaped in strings", e.g.

^4chan-url: http://www.4chan.org/

Yet expanding this to the likes of ^[ might have a cost, in that you should be using the codepoint form ^(...) instead. Further emphasizing that ^( won't work as an escape, and should be in codepoint form as well.

In this vein, we might consider the idea of escaping newlines with something that isn't so entrenched as a block-structure character as slash is. The idea was floated to use ^| instead. If this were supported inside strings as well as outside, while the ^/ form was kept inside strings as being legal, it could be properly forward-compatible.

So perhaps people can think on if they feel ^| is somehow intrinsically worse than ^/ for newline. All things being equal in terms of pressing the shift key and such maybe it's not as good, but it seems to be more or less the same...and not conflict with PATH!.

Date User Field Action Change
13-Mar-2015 12:25 Fork Comment : 0004609 Modified -
13-Mar-2015 12:24 Fork Comment : 0004609 Modified -
13-Mar-2015 12:23 Fork Comment : 0004609 Added -
13-Mar-2015 10:33 MarkI Comment : 0004605 Modified -
13-Mar-2015 10:33 MarkI Comment : 0004605 Modified -
13-Mar-2015 10:25 MarkI Comment : 0004608 Added -
13-Mar-2015 09:57 abolka Comment : 0004606 Added -
13-Mar-2015 09:36 MarkI Comment : 0004605 Added -
13-Mar-2015 07:48 abolka Description Modified -
13-Mar-2015 07:43 abolka Description Modified -
13-Mar-2015 07:42 abolka Ticket Added -