ELisp: Quote and Dot Notation

By Xah Lee. Date: .

Dot Notation '(a . b)

(cons a b)

can be written as

'(a . b)

or

(quote (a . b))

when you do not need to eval the arguments. (that is, they are symbol, string, or number.)

;; (cons x y)
;; is same as
;; (quote (x . y)
;; when x and y are symbols or number or string

(equal (cons 3 4)
       (quote (3 . 4)))
;; t

(equal (cons "3" "4")
       (quote ("3" . "4")))
;; t

(equal (cons 'x 'y)
       (quote (x . y)))
;; t

;; HHHH---------------------------------------------------

;; (quote (x . y))
;; can be written as
;; '(x . y)

(equal (quote (3 . 4))
       '(3 . 4))
;; t

(equal (quote ("3" . "4"))
       '("3" . "4"))
;; t

(equal (quote (x . y))
       '(x . y))
;; t

(cons x y)

is not equal to

(quote (x . y)

when x and y are variables and you want their values.

;; (cons x y)
;; is not equal to
;; (quote (x . y)
;; when x and y are not symbols or number or string

(let (x y)
  (setq x 3 y 4)
  (equal (cons x y)
         (quote (x . y))))
;; nil

Emacs Lisp List

Special Lists

List Structure