From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Florian Beck Newsgroups: gmane.emacs.help Subject: Re: How does letf work? Date: Wed, 29 Jan 2014 21:19:39 +0100 Message-ID: <52E9625B.80207@miszellen.de> References: <52E838C8.5020101@miszellen.de> <52E91E74.8060204@miszellen.de> <877g9ihim7.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1391026807 23237 80.91.229.3 (29 Jan 2014 20:20:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jan 2014 20:20:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 29 21:20:13 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 1W8bcJ-0000nw-II for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 21:20:11 +0100 Original-Received: from localhost ([::1]:45183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8bcJ-0002tU-4E for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 15:20:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8bc2-0002sP-Aa for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 15:20:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8bbw-0003Y0-FU for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 15:19:54 -0500 Original-Received: from mo6-p04-ob.smtp.rzone.de ([2a01:238:20a:202:5304::4]:52517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8bbw-0003XO-17 for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 15:19:48 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1391026785; l=1060; s=domk; d=streitblatt.de; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References: Subject:CC:MIME-Version:From:Date:To:X-RZG-AUTH:X-RZG-CLASS-ID; bh=APntzH19rKTUzpOR0wdPFT0tWa4=; b=FUqLH0g9kyqHxCZjG6I9qwT6v9LVHTVZ3iYxoH8MPLsur1xH3uEdTr9juUDg2FfcJd7 PUGR0quY807Ee9002UxDS6Fg0P4soHiHNDwz+Jkf1Ayjs1OsC5RlxfeEcOY6mwWVsV2Z2 nlE+pF2VDvUfj+M8PsPrMKdruJQigKR8EtM= X-RZG-CLASS-ID: mo04 X-RZG-AUTH: :KmALZ0mpdbGonPxw7gDkop508XQjelhLxGYn4B74/iddlkME3ssvHN/NVnKdtguvGeN0dEmu6+Ee Original-Received: from [10.42.20.137] ([89.204.138.137]) by smtp.strato.de (RZmta 32.22 SBL|AUTH) with ESMTPSA id C02a7dq0TKJhUs0 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) for ; Wed, 29 Jan 2014 21:19:43 +0100 (CET) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <877g9ihim7.fsf@yahoo.fr> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:238:20a:202:5304::4 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:95761 Archived-At: Thank you, I think I got it now. If I understand correctly, it works like this: {1} means pointer to cons cell 1; <...> means a shadowed cons cell Simplified example. (letf* ; x undefined ((x '(A B)) ; x={1} 1=[A|{2}] 2=[B|()] ((cdr x) '(C))) ; <2=[C|()]> x ; x={1} 1=[A|{2}] <2=[C|()]> ) ; returns {1}, i.e. pointer to cell {1} ; which still point to {2}, but {2}'s ; original value has been restored Same with car: (letf* ; x undefined ((x '(A B)) ; x={1} 1=[A|{2}] 2=[B|()] ((car x) 'D) ; <1=[D|{2}]> ((cdr x) '(C))) ; <2=[C|()]> x ; x={1} <1=[A|{2}]> <2=[C|()]> ) ; returns {1}, but both cons cells have ; been restored But with setf, setcar, etc., there is nothing to restore: (letf* ; x undefined ((x '(A B))) ; x={1} 1=[A|{2}] 2=[B|()] (setcar x 'C) ; 1=[C|{2}] x) ; returns pointer to {1}, which wasn't ; shadowed, so nothing to restore. (Obviously, we don't need letf in the last example.) Right? Let returns the "value of the last form". Straightforward in hindsight. -- Florian Beck