emacs lisp cons

lisp cons problem

proper name for the issue is perhaps violating equality transitivity.

(equal (cons 3 4) '(3 . 4)) ; t
(equal (cons 'x 4) '('x . 4)) ; nil
;; but
(equal 'x 'x) ; t

making excuse for bad design by technicality is no good.

(equal (cons 3 4) '(3 . 4)) ; t
(equal (cons 'x 4) '('x . 4)) ; nil
;; but
(equal 'x 'x) ; t
;; computer science, functional programing: referential transparency.

;; this is when referential transparency is violated in lisp

(equal (cons 3 4)
        '(3 . 4))
;; true

;; now, replace the expression 3 by 'x

(equal (cons 'x 4)
        '('x . 4))
;; false

;; fuck the lisp fanantics fuckheads, in particular the Common Lispers, with their obsession on the lisp reader fucking up the meaning of syntax in computer science by their own cult definition of syntax
(equal (cons 'x 4) '(x . 4))
;; true

;; now replace 4 by '4

(equal (cons 'x '4) '(x . '4))
;; false

in other lang, if if ([a,b] == [a,b]) is true so is replacing a and b by other expressions

(equal
 (cons 3 3)
 '(3 . 3))
;; true

;; but
(equal
 (cons 'a 3)
 '('a . 3))
;; false

(equal (quote a) 'a)
;; true

deep dive cons, quote, reader.

(eq t t)
;; t

(eq nil nil)
;; t

(eq 'e (quote e))
;; t

(eq 3 (quote 3))
;; t

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

(equal
 'a
 (quote a))
;; t
;; 2023-08-11

(eq (list 3) (list 3))
;; nil

(equal (list 3) (list 3))
;; t

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

(equal (cons 'a 'b)
       '(a . b))
;; t

(equal (cons 'a 'b)
       (quote (a . b)))
;; t

(equal
 '(("a" . aa)
   ("b" . bb))
 (list
  (cons "a" 'aa)
  (cons "b" 'bb)))
;; t

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

;; when an element is quoted, quote must not be nested

(eq
 (equal (cons 'a 'b)
        '('a . 'b))
 nil
 )

emacs lisp quote

;; explore the syntactic equivalence of quote and its shorthand '

;; all return t
(equal 3 3)
(equal 3 (quote 3))
(equal '3 (quote 3))
(equal 3.1 (quote 3.1))
(equal '3.1 (quote 3.1))
(equal 'x (quote x))

;; this means, for numbers and symbols, both forms are equivalent
;; probably true for any atom

;; all return t
(equal '(3) (quote (3)))
(equal '(3 4) (quote (3 4)))
(equal '(3 x) (quote (3 x)))

;; this means, for paren, both forms are equivalent

;; in general, we might conclude, that any of the form
;; (quote ‹x›)
;; is identical to
;; '‹x›

;; except when the ‹x› is some special emacs lisp reader form.

;; or, a better way to say this is that, the lisp reader, will take a text stream or string, and return a sorta internal lisp object form.
;; and, in emacs lisp source code,
;; (quote ‹x›)
;; and
;; '‹x›
;; almost always result the same internal lisp form.

;; ssss---------------------------------------------------
;; now lets look at cons

(equal (list 3 4)
       (quote (3 4)))
;; t

;; interesting, because the arg forms r different, but equivalent anyway.
;; this is so because, lisp reader converts (list 3 4) to just (3 4), and the quote function, return its arg from reader.

;; if you do this,
(equal (3 4)
       (quote (3 4)))
;; you get (invalid-function 3)

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

(equal (cons 3 4)
       (quote (3 4)))
;; nil

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

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

(equal  '(a . b)
        (cons 'a 'b))
;; t

(equal  ('a . 'b)
        (cons 'a 'b))
;; error

;; ssss---------------------------------------------------

(3 . nil)
;; (invalid-function 3)

('3 . nil)
;; (invalid-function '3)

;; (quote ARG)
lisp quote 2023-08-12 VtS7
lisp quote 2023-08-12 VtS7
;; lisp cons and quote and reader FUCK
;; FUCK the lispers
(setq xxa (list 'a 'b))
(setq xxb (list 'a . ('b)))

(equal xxa xxb)
;; t
lisp cons problem 2023-08-12
lisp cons problem 2023-08-12