From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.help Subject: Re: How does letf work? Date: Wed, 29 Jan 2014 17:12:48 +0100 Message-ID: <877g9ihim7.fsf@yahoo.fr> References: <52E838C8.5020101@miszellen.de> <52E91E74.8060204@miszellen.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1391012063 29327 80.91.229.3 (29 Jan 2014 16:14:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jan 2014 16:14:23 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Florian Beck Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 29 17:14:29 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W8XmW-0004wg-J6 for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 17:14:28 +0100 Original-Received: from localhost ([::1]:43581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8XmW-0005Y7-5I for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 11:14:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8XmF-0005W7-R3 for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 11:14:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Xm9-0008Hj-HV for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 11:14:11 -0500 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:45526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Xm9-0008HL-BM for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 11:14:05 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EAJwn6VKkD4Xx/2dsb2JhbABZwRmBHXSCJgEBBHkQCAMOEyUPAQRJE4dwARSrHJYIAYhhF4dxhw4HhDgEmCiGMYtugy47gSwk Original-Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 29 Jan 2014 17:12:44 +0100 In-Reply-To: <52E91E74.8060204@miszellen.de> (Florian Beck's message of "Wed, 29 Jan 2014 16:29:56 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 164.15.128.112 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95754 Archived-At: Florian Beck writes: > > (letf* ((x (copy-list test-x)) > ((cdr x) '(a b c d))) > x) > > => (KEY 1 2 3 4) > > I'm still confused. test-x, which I recall is (KEY 1 2 3 4) here, is simply a cons cell. Its car is KEY, its CDR is (1 2 3 4). After the first line of the letf*, test-x and x are different cons cells. In fact their CAR are `eq', and their CDR are not. OTOH nothing of this is relevant, test-x doesn't matter here. After the second line, you changed the CDR of x to the list '(a b c d). But that is a temporary binding that'll be reverted as soon as we exit the letf* form. At the third line, before the closing paren, you say: return the value of x, so you indeed get that cons cell, which is '(KEY a b c d). But now, the closing paren happens, i.e. letf* does its job and reverts the variable value of x to what is was before (empty, I presume, making x an unbound symbol) and the place represented by (cdr x), i.e. the cdr of the cons cell that just got returned, to its initial value: '(1 2 3 4). So when letf returns, the cons cell that we received changes. And that's what gets printed. -- Nico.