[plt-scheme] Semantics of quote

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Mon Jun 23 15:45:14 EDT 2008

My mental model is usually to think of quote as a keyword that
prevents the contents from explicitly being evaluated (so 'a means
don't evaluate the a as variable, just think of it as symbol, and '(a
b c) means not to treat the list as a function application, but just
the actual list).  I don't really deal much with nested quotations, or
think much about the printing aspect, so my mental model is clearly a
bit naive, but it works for common purposes.  Perhaps I once had a
deeper mental model of quote, but after being away from Scheme for
many years, this is what I retained.  I never expected that consing in
the atom 'quote into a list would trigger the quotation printing
mechanism.  It makes me wonder what else I'm forgetting about quote.

--Mark

On Mon, Jun 23, 2008 at 12:15 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> Yeap, isn't it confusing? :-)
>
> Quoted expressions are self-evaluating, but not self-printing a point of
> endless confusion to beginners -- as you may recall from 1991.
>
>
> On Jun 23, 2008, at 3:08 PM, Mark Engelberg wrote:
>
>> Some examples:
>>
>> (cons 'quote (cons 'a empty)) prints as 'a
>
>
> But what does 'a mean? Where did it come from? How does
>
> 'a print in a "real" Scheme, after evaluating to itself?
> ''a print in a "real" Scheme, after evaluating to itself?
> '''a print in a "real" Scheme, after evaluating to itself?
> ''''a print in a "real" Scheme, after evaluating to itself?
>
> -- Matthias
>
>
>
>
>>
>> Consider:
>> (define-syntax my-quote
>>  (syntax-rules ()
>>    ((my-quote expr)
>>     (quote expr))))
>>
>> (quote (quote a))
>> and
>> (quote (my-quote a))
>>
>> yield different outputs.
>>
>> --Mark
>>
>> On Mon, Jun 23, 2008 at 7:52 AM, Jos Koot <jos.koot at telefonica.net> wrote:
>>>
>>> Can you be somewhat more specific? What kind of subtle things do you
>>> encounter?
>>> jos
>>> ----- Original Message ----- From: "Mark Engelberg"
>>> <mark.engelberg at gmail.com>
>>> To: "pltscheme" <plt-scheme at list.cs.brown.edu>
>>> Sent: Monday, June 23, 2008 6:25 AM
>>> Subject: [plt-scheme] Semantics of quote
>>>
>>>
>>>> Can anyone point me to a fairly precise explanation of quote?
>>>> Sometimes I encounter subtle things that make me wonder whether my
>>>> mental model of how quote works is accurate.
>>>>
>>>> --Mark
>>>> _________________________________________________
>>>>  For list-related administrative tasks:
>>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.