Opened 6 years ago

Closed 5 years ago

#304 closed defect (fixed)

symbol literal syntax wastes characters

Reported by: alexshinn Owned by: cowan
Priority: major Milestone:
Component: WG1 - Core Keywords:
Cc:

Description

[Based on feedback from Marc Feeley.]

Currently symbols can either be delimited with pipes |...|
with optional hex escapes inside, or include hex escapes
directly without the pipes. This wastes two characters
that were reserved in R5RS, the pipe and the backslash,
when either one by itself would be sufficient to represent
all symbols. This is especially unfortunate because both
characters are used as extensions in various Schemes -
the pipe being another symbol character in SCSH (to
represent shell-style pipes and C-style operators) and
the backslash used in Gambit's infix syntax. We should
reconsider if we really need to take up both of these
characters.

Change History (7)

comment:1 Changed 6 years ago by cowan

If we are to drop one syntax, it must be the hex escape syntax, because it is incomplete: it can't represent the value of (string->symbol ""). However, we will still need hex escapes inside pipes, or the value of (string->symbol "|") cannot be represented (nor any other symbol containing a pipe); furthermore, symbols containing control characters would be problematic for humans to read or write.

In simple cases the pipe syntax is much clearer than hex escapes, and it is widely supported, in particular by Racket, Gauche, MIT, Gambit, Chicken, Bigloo, SISC, Chez, Ikarus, STklos, KSi, Oaklisp. Scsh, SCM, Scheme 9, Scheme 7, Elk, UMB, VX treat | as an ordinary symbol character, though only scsh seems to have a specific use for it; Scheme48, Larceny, Ypsilon, Mosh, SigScheme throw errors; IronScheme got confused (or perhaps I did).

Support for the hex escape syntax is more limited. The R6RS Schemes Chez, Ikarus, Larceny, Ypsilon, Mosh, IronScheme support it as expected; for whatever reason, the default Racket REPL does not. I tested the remaining Schemes listed above with the form 'a\x46b, which should evaluate to aFb under the R6RS rules: that works only on Kawa, Scheme48, KSi. All other Schemes listed above treat ;b as a comment and do random things with the a\x46 part.

comment:2 Changed 6 years ago by alexshinn

Technically we could allow \0 or similar for the empty symbol,
or use \xNN for a single escape and \|...| for the equivalent of
the current pipe escape.

comment:3 Changed 5 years ago by cowan

\0 is yucky.

Let's stick with pipes and allow hex syntax only inside them. This is mildly incompatible with R6RS, I admit, but I don't think it matters that much. Few people will use these syntaxes in anger anyway. Escaped pipes sound good in principle, but nobody supports them.

comment:4 Changed 5 years ago by cowan

The WG voted to adopt this proposal, allowing hex escapes only within identifiers within vertical bars. Outside such identifiers, \ is not special.

comment:5 Changed 5 years ago by cowan

  • Status changed from new to decided

comment:6 Changed 5 years ago by cowan

  • Owner changed from alexshinn to cowan
  • Status changed from decided to writing

comment:7 Changed 5 years ago by cowan

  • Resolution set to fixed
  • Status changed from writing to closed
Note: See TracTickets for help on using tickets.