[e-lang] Unquoted backslashes for identifier escapes?

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Thu Jan 15 15:56:41 CST 2009


Kevin Reid wrote:
> The ::"foo bar" syntax for noun strings is rather ugly and not well- 
> justified.
> 
> How about, replacing the current noun-string and verb-string, allowing  
> backslash escapes in identifiers, which would work uniformly rather  
> than being different for nouns and verbs?
> 
> That is:
> 
> Current                New
> ::"foo bar"            foo\ bar
> c."add(Component)"(d)  c.add\(Component\)(d)
> 
> Actually, I can think of one disadvantage already: the quote syntax  
> permits the empty string, whereas backslashes need at least one  
> character to escape. Not that it's *sensible* to use the empty string  
> for an identifier, but the regularity is good.
> 
> Common Lisp uses essentially this approach for symbol names -- the  
> escaping is uniform -- but it has a "multiple escape" which is  
> essentially quotes:
> 
> add\(Component\)   single escape
> |add(Component)|   multiple escape
> ||                 empty-string-named symbol using multiple escape
> 
> What comes to mind to have such a syntax in E is:
> 
> \"foo bar"
> \"add(Component)"
> \""
> 
> But that is rather peculiar and inconsistent with other uses of  
> backslash.

Smalltalk uses # for symbol names. Perhaps

  #"foo bar"
  c.#"add(Component)"(d)

or

  #foo bar#
  c.#add(Component)#(d)

?

(In the first case, # is a prefix operator taking a string to a symbol.
In the second, #...# is a new literal syntax for symbols that uses the
same internal escaping as "..."; \# would be added to the escapes for
both strings and symbols. Note that this avoids lexical ambiguities that
would be introduced by using '|'.)

-- 
David-Sarah Hopwood ⚥



More information about the e-lang mailing list