Search code examples
emacsquote

Why isn't 'emacs the same as 'emacs here?


This first one should return t but isn't doing so, while the other is returning t. They should be the same.

(defvar list '((binds . 'emacs)))
(eq (cdr (assoc 'binds list)) 'emacs) ;; returns nil
(eq 'emacs 'emacs) ;; returns t
(type-of 'emacs) ;; returns symbol
(type-of (cdr (assoc 'binds list))) ;; Returns cons

What is going on here?


Solution

  • Because

    (equal (cdr (assoc 'binds list)) ;; (quote emacs)
           (quote (quote emacs))
    

    i.e. the cdr part returns 'emacs while 'emacs returns just the symbol itself without the quote.