Subject: Re: reading symbols preserving case
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 02 Apr 2009 20:26:57 -0500
Newsgroups: comp.lang.lisp
Message-ID: <IqadnQZ4scR8-EjUnZ2dnUVZ_vWdnZ2d@speakeasy.net>
Marek Kubica  <marek@xivilization.net> wrote:
+---------------
| Francisco Vides Fernández <fvides@dedaloingenieros.com> wrote:
| > This is possible in SCSH because the original author, Olin Shivers,
| > modified the scheme reader (in fact SCSH isn't a fully compliant
| > scheme because of this).
| 
| Starting with R6RS the language is case-preserving anyway.
+---------------

I don't think Shivers had to modify the Scheme reader at all, since in
Scheme there is a *standard* mapping from the usual three "backquote"
readmacros to forms -- QUASIQUOTE, UNQUOTE, & UNQUOTE-SPLICING -- and
a "naked comma" is *NOT* illegal in Scheme's READ per se!

    > (read)
    ,foo				<=== I typed this.
    (unquote foo)
    > (read)
    ,@foo				<=== I typed this.
    (unquote-splicing foo)
    > (read)
    (let ((hi "hello world"))		<=== I typed this.
      (run/string (echo ,hi)))
    (let ((hi "hello world")) (run/string (echo (unquote hi))))
    > 

Whereas in Common Lisp:

    > (read)
    ,foo
    Reader error at 13 on #<Two-Way Stream, Input = #<Synonym Stream to SYSTEM:*STDIN*>, Output = #<Synonym Stream to SYSTEM:*STDOUT*>>:
    Comma not inside a backquote.
       [Condition of type READER-ERROR]
       ...
    ...[enters debugger]...

That's why it's so hard to do a SCSH-like thing in CL.
[It can be done, but you have to tweak SCSH's RUN syntax a bit,
and the tweaks aren't portable because of the lack in CL of a
standard-required mapping from "`"/","/",@" to forms.]


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607