Eli Gottlieb <eligottlieb@gmail.com> wrote:
+---------------
| Rob Warnock wrote:
| > Yup. This is one place where Scheme got it right, IMHO, by at least
| > standardizing the name of the quasiquotation macro and the associated
| > internal syntax markers -- QUASIQUOTE, UNQUOTE, and UNQUOTE-SPLICING --
| > http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.6
| > Also, by making QUASIQUOTE an explicit operator ("syntax", but it
| > could have been a macro in CL), it allows the embedding of "implicit
| > quasiquotation" in the forms of *other* wrapper macros, such as are
| > used by the Scheme Shell, for example. [I have written elsewhere
| > (several times) on why the lack of such standarization makes it
| > practically impossible to write a "CL Shell" with Scsh-style syntax.]
|
| Why couldn't you do similar things in CL? All a quasiquote does is
| stand in for explicit list construction!
+---------------
In CL perhaps [though even there the situation is a little more
complicated than you imply -- it is a stand-in for construction
of a *code* sequence that, when evaluated, will perform an explicit
list construction], but in Scheme the separation between the reader
and the evaluator is complete: *All* the reader does is change the
`,,@ markers to QUASIQUOTE, UNQUOTE, and UNQUOTE-SPLICING forms
(respectively); it is the evaluator which "executes" the resulting
QUASIQUOTE forms. And in particular, even though R5RS warns that:
Unpredictable behavior can result if any of the symbols
QUASIQUOTE, UNQUOTE, or UNQUOTE-SPLICING appear in positions
within a <QQ template> otherwise than as described above.
all Scheme systems I have access to allow the reading of "isolated"
or "improperly-nested" UNQUOTE and UNQUOTE-SPLICING subforms, e.g.:
> (quote (a ,b ,@(c d) e))
==> (a (unquote b) (unquote-splicing (c d)) e)
>
This means that *other* macros besides QUASIQUOTE can use those
forms [albeit by doing a tree walk and interpreting the embedded
UNQUOTE and UNQUOTE-SPLICING subforms], which is what happens in
Scsh, allowing one to write things like this:
(let ((foo "filename")) ; RUN is a Scsh macro that does what
(run (ls -l ,foo))) ; might be called "implicit quasiquoting".
(run (cc ,file ,@flags)) ; Compile FILE with FLAGS.
Unfortunately those are illegal to a standard CL reader, so in a
(hypothetical) "CLsh" the above would have to look like this:
(let ((foo "filename"))
(run `(ls -l ,foo))) ; Note explicit backquote
(run `(cc ,file ,@flags)) ; (ditto)
This is why I said it's "practically impossible to write a CL Shell
with Scsh-style syntax" [unless you manually add explicit backquotes
at various points].
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607