[plt-scheme] Semantics of quote

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Mon Jun 23 15:53:49 EDT 2008

On Mon, Jun 23, 2008 at 12:08:29PM -0700, Mark Engelberg wrote:
> Some examples:
> (cons 'quote (cons 'a empty)) prints as 'a
> Consider:
> (define-syntax my-quote
>   (syntax-rules ()
>     ((my-quote expr)
>      (quote expr))))
> (quote (quote a))
> and
> (quote (my-quote a))
> yield different outputs.

As Matthias's reply points out, the REPL's printer treats (quote ...)
specially, which leads to confusion in certain cases.

It's also worth pointing out that you get the same output from your second
example above even if you leave out the definition of `my-quote'.  The
built-in `quote' form suppresses not only evaluation of its argument but
also macro expansion.  Therefore,

    (equal? (quote my-quote a)
            (cons 'my-quote (cons 'a null)))

is #t, both with and without the definition of the `my-quote' macro.


Posted on the users mailing list.