From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Louis-Guillaume Gagnon Newsgroups: gmane.emacs.help Subject: Question about let binding behavior Date: Tue, 08 Oct 2024 06:21:03 +0000 Message-ID: <88c7526c-b7d9-46f8-8799-5825b97d20ba@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30541"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 08 08:21:47 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sy3bN-0007ja-NC for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Oct 2024 08:21:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sy3as-00019v-3T; Tue, 08 Oct 2024 02:21:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sy3aq-00019m-Sx for help-gnu-emacs@gnu.org; Tue, 08 Oct 2024 02:21:12 -0400 Original-Received: from mail-4322.protonmail.ch ([185.70.43.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sy3ao-0002v1-V4 for help-gnu-emacs@gnu.org; Tue, 08 Oct 2024 02:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1728368467; x=1728627667; bh=sFLsj1ncXWAIGJSd7GVEHqiX+1WEn5iJVF/HpzPizfo=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=eaTHMA4I0mak/xd6A4vgskos/2Qs8cCTMhK/XyAIQRr+ZrLadr0bOY0edSURbbslN qV7NNlHBxR5JQIUSBhwvJKXYIGdx/6aR8eJxxXpvCXZOUG8psc12V6xllHNQ8KSCxU Zf8VWmFjl3cE6UmbHG7r9OomnSqFmnl6zgYsygu/SkyraDmr3EII0d9rsF0qs8h7I1 CNxjUwKgXYSjkxjaNz3o8TfXwfIXKH+kB8ZEXlsIbI3SrFV4hA4xrDLmlnmKGS6cJz wbGKlGXG9sv8sQGR38nbh5CIcapFy3K/29a++2BGPaDlp/Ij7ntVdUpxyNBUZrfFQc 6QpWVDLnsvCtg== Feedback-ID: 19925570:user:proton X-Pm-Message-ID: 8e76ec4736211dd44ca80389f5af41b676242028 Received-SPF: pass client-ip=185.70.43.22; envelope-from=gagnonlg@protonmail.com; helo=mail-4322.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148129 Archived-At: Dear all, I'm a long time user but I've only recently started to dive into elisp=20 programming. I'm a bit surprised by the following behavior. Let's say I write the following silly function: (defun foo (bar) =C2=A0 (let ((baz '((quux . 0) (quuz . 0)))) =C2=A0=C2=A0=C2=A0 (if (> 10 bar) =C2=A0=C2=A0=C2=A0 (setcdr (assoc 'quux baz) bar) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setcdr (assoc 'quuz baz) bar)) =C2=A0=C2=A0=C2=A0 baz)) Then the following evals: (foo 1) =3D> ((quux . 1) (quuz . 0)) (foo 100) =3D> ((quux . 1) (quuz . 100)) I'm surprised that the list is not reset since I thought the binding was=20 local to the function, but clearly I don't have the right mental model=20 for elisp evaluation. For the actual application I ended up using=20 copy-tree but I'd like to understand this better -- could someone=20 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