[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question about let binding behavior
From: |
Louis-Guillaume Gagnon |
Subject: |
Question about let binding behavior |
Date: |
Tue, 08 Oct 2024 06:21:03 +0000 |
Dear all,
I'm a long time user but I've only recently started to dive into elisp
programming. I'm a bit surprised by the following behavior.
Let's say I write the following silly function:
(defun foo (bar)
(let ((baz '((quux . 0) (quuz . 0))))
(if (> 10 bar)
(setcdr (assoc 'quux baz) bar)
(setcdr (assoc 'quuz baz) bar))
baz))
Then the following evals:
(foo 1)
=> ((quux . 1) (quuz . 0))
(foo 100)
=> ((quux . 1) (quuz . 100))
I'm surprised that the list is not reset since I thought the binding was
local to the function, but clearly I don't have the right mental model
for elisp evaluation. For the actual application I ended up using
copy-tree but I'd like to understand this better -- could someone
explain or point out the relevant sections of the manual?
Cheers,
L-G
P.S. Please keep me in CC, I'm not subscribed to this list
- Question about let binding behavior,
Louis-Guillaume Gagnon <=
- Re: Question about let binding behavior, tomas, 2024/10/08
- Re: Question about let binding behavior, Louis-Guillaume Gagnon, 2024/10/08
- Re: Question about let binding behavior, tomas, 2024/10/08
- Re: Question about let binding behavior, tomas, 2024/10/08
- Re: Question about let binding behavior, Louis-Guillaume Gagnon, 2024/10/09
- Re: Question about let binding behavior, Tomas Hlavaty, 2024/10/09
- Re: Question about let binding behavior, Stefan Monnier, 2024/10/09
- Re: Question about let binding behavior, Tomas Hlavaty, 2024/10/10
- Re: Question about let binding behavior, Stefan Monnier, 2024/10/10
- Re: Question about let binding behavior, Rudolf Schlatte, 2024/10/18