Search code examples
emacselispparentheses

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


I'm doing a tutorial on emacs lisp, and it's talking about the let function.

;; 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 don't understand the role of the double parentheses after let in the first line. What are they doing that a single set wouldn't do? Running that section without them, I get an error: Wrong type argument: listp, "you".


Solution

  • You can introduce multiple variables there. The outer parentheses delimit the list of bindings, the inner the individual binding form.

    (let ((foo "one")
          (bar "two"))
      (frobnicate foo bar))