[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: here strings and symbols




> At Tue, 12 Jul 2005 12:03:28 +0200, Sebastian Egner wrote:
> > It struck me that the new lexical syntax for symbols is also just a 'here
> > string',
> > albeit with the fixed key "|".
>
> I don't understand. I think the new lexical syntax for quoted symbols
> is that of a normal quoted string, but with the start and end character
> as | instead of ". It's not at all like a here string, because escapes
> in the quote symbol work the same as in a quoted string.

You are right, there is a fixed delimiter ('|') just as
in the string case ('"'); what I mean is the following:

The purpose of an escape mechanism is to enable the inclusion
of more symbols into the string than are available in the alphabet.
However, it implies that you have to escape the escape characters
themselves and also the delimiter characters. Now, in practice
this means the escape mechanism differs by type; so if you write
a string you need to escape '"' and if you write a symbol you
need to escape '|' but not '"':

        Section "Symbol Lexical Syntax":
        Unlike strings, double-quote characters that are part of
        the symbol need not be escaped, whereas vertical-bar characters
        in the symbol must be escaped.

This sort of definition is logical but also more complicated than
necessary, which is no problem until the day you have programs
manipulating the names of strings and symbols and externalizing
them in different formats. If there would only be one mechanism
for escaping this would become simpler.

> > Wouldn't it make more sense to have two forms of 'here string,' one
> > within a line and one spanning several lines, and then having a
> > modifier indicating string or symbol?
>
> I'm having trouble imaging a use for "here symbols". Did you have
> something in particular in mind?

Well, writing symbols from different languages. I understand that
the additional lexical syntax for symbols is intended to include
all sorts of things, e.g. whitespace, without using string->symbol.
Now if I generate external representations of symbols from other
programming languages and write them into a file, I still need
some sort of quoting mechanism to produce the proper '|'-form.

There are of course tons of ways to interpret this, but for
me symbols and strings are completely identical, except that
symbols are internalized and have fewer operations defined on them.
With this idea of symbols and strings, it is natural to see them
be treated in the same way. Unfortunately, quote (') has a certain
meaning already, otherwise I would to make '<string literal> a symbol.

Sebastian.