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"
.
There are not "double parens".
Presumably, you are thinking of (let ((foo...)...))
, and you mean the ((
that come after let
? If so, consider this:
(let (a b c) (setq a 42)...)
IOW, let
declares local variables. It may also bind them. In the previous sexp, it declares a
, b
, and c
, but it doesn't bind any of them, leaving it to the let
body to give them values.
An example that declares two variables but binds only one of them (a
):
(let ((a 42) b) ... (setq b ...) ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With