3

In On Lisp (p. 84) Graham says

‘(a b c) (without comma) is equal to ’(a b c)

and then says

A backquoted list is equivalent to a call to list with the elements quoted.
That is, ‘(a b c) (without comma) is equal to (list ’a ’b ’c).

One statement has to be false since '(a b c) and (list 'a 'b 'c) don't seem to be equal. The latter is a freshly consed list (safe to modify) while the former is a constant -- or at least the spec allows the compiler to treat it as such.

So maybe it's a very nitpicky question but is a backquoted list (without comma) like ‘(a b c) equal to '(a b c) or equal to (list 'a 'b 'c)?

Frank
  • 433
  • 3
  • 10
  • The list produced by backquote is allowed to share structure with the template itself, so it's not safe to mutate. How it actually works is up to the implementation. – jkiiski Jun 02 '17 at 18:53

1 Answers1

6

Equal and Equivalent are not the same.

Certainly (equal '(a b c) (list 'a 'b 'c)) returns t, but, as you correctly note yourself, '(a b c) is a quoted constant while (list 'a 'b 'c) is freshly allocated.

sds
  • 58,617
  • 29
  • 161
  • 278
  • 2
    Ah, ok, so Graham says they are all equal with regard to the relational operator `equal` which I confused with equivalence. – Frank Jun 02 '17 at 19:40