[racket-dev] A curious question about quote

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jan 27 01:43:01 EST 2011

2011/1/26 J. Ian Johnson <ianj at ccs.neu.edu>:
> Hello all. I have a historical question about quoted constants. Does anyone know why '1 = 1?
> My intuition is that this is an artifact of conflating quote with list constructors. Is that indeed the case?

Depends on what you think of, when you say "conflating quote with list
constructors",
but my first reaction was to say no.

An expression of the type:  quote followed by the written
representation of a value v
should evaluate to a value equal (in the sense of equal?) to v.

More succintly:      '<written representation of v> evaluates to a
value equal? to v

Since the written representation of the value 1 is 1, the expression
'1 will evaluate to 1.

Since the written representation of a list with elements 1 and 2 are
(1 2), the expression
'(1 2) will evaluate to a value equal? to the value resulting from an
evaluation of (list 1 2).

Since '<something> is syntactic sugar for (quote <something>), the expression
  '('1 '2) is equivalent to the expression '((quote 1) (quote 2)).
That expression evaluates to a value equal? to the value resulting
from the expression
  (list (list 'quote 1) (list 'quote 2))
which explains your first example:

  >> (equal? '('1 '2) '(1 2))
  > #f

-- 
Jens Axel Søgaard


Posted on the dev mailing list.