-1

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?

Drew
  • 29,895
  • 7
  • 74
  • 104
  • 1
    In fact they *shouldn't* be the same -- and indeed they are not. You would be better to phrase such a question as "I thought that they would be the same, but they are not. Why is that?" – phils Jul 10 '20 at 10:19
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Jul 10 '20 at 15:31
  • "hahahahahahha" is different from hahahahahahha. `(eq ''emacs 'emacs)` is `nil`, that's all. The first arg of `eq` evaluates to the list `(quote emacs)`; the second arg evaluates to the symbol `emacs` - two different animals. – Drew Jul 10 '20 at 15:35

1 Answers1

2

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.

choroba
  • 231,213
  • 25
  • 204
  • 289