Why are there two parentheses after `let` in emacs lisp?

I am doing a tutorial on emacs lisp and it talks about the function let.

;; You can bind a value to a local variable with `let':
(let ((local-name "you"))
  (switch-to-buffer-other-window "*test*")
  (erase-buffer)
  (hello local-name)
  (other-window 1))

I do not understand the role of double brackets after letin the first line. What do they do that one set will not do? Running this section without them, I get an error message: Wrong type argument: listp, "you".

+4
source share
4 answers

Here you can enter several variables. Outer parentheses restrict the list of bindings, and inner parentheses are an individual form of binding.

(let ((foo "one")
      (bar "two"))
  (frobnicate foo bar))
+8
source

There are no "double parsers".

, (let ((foo...)...)), ((, let? , :

(let (a b c) (setq a 42)...)

IOW, let . . sexp a, b c, , let, .

, , (a):

(let ((a 42) b) ... (setq b ...) ...)
+4

gnu.org, , let, .

varlist , , let :

(let ((variable value)
      (variable value)
      …)
  body…)
+2

let : (let (<binding-form> ...) <body>).

<symbol> ( , nil) (<symbol> <value>) ( let).

let let* , . let :

(let ((a 17) 
      (b 42)) 
  (let ((a b)  ; Inner LET
        (b a)) 
    (list a b)))

let* . , let, (let* (<form1> <form2>...) (let (<form1>) (let (<form2>) ...))

+2

Source: https://habr.com/ru/post/1609141/


All Articles