From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: How does letf work? Date: Thu, 30 Jan 2014 00:46:42 +0100 Message-ID: <87sis62vx9.fsf@web.de> References: <52E838C8.5020101@miszellen.de> <87txcmq13g.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1391039243 7365 80.91.229.3 (29 Jan 2014 23:47:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jan 2014 23:47:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 30 00:47: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 1W8eqs-0000oH-RQ for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jan 2014 00:47:26 +0100 Original-Received: from localhost ([::1]:45662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8eqs-0008Uc-HC for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 18:47:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8eqa-0008UT-PF for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 18:47:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8eqU-0000ad-KZ for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 18:47:08 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:40399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8eqS-0000Zz-BX for help-gnu-emacs@gnu.org; Wed, 29 Jan 2014 18:47:02 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W8eqR-0000Xc-De for help-gnu-emacs@gnu.org; Thu, 30 Jan 2014 00:46:59 +0100 Original-Received: from ip-90-186-253-188.web.vodafone.de ([90.186.253.188]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 30 Jan 2014 00:46:59 +0100 Original-Received: from michael_heerdegen by ip-90-186-253-188.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 30 Jan 2014 00:46:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-253-188.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:cqImq5FWju5JvYfZIyB4GkOYPug= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:95771 Archived-At: Nicolas Richard writes: > How I understand it is : what is returned by the letf *is* the value of > the symbol, but since it is a cons cell it can be modified by setf > (using setcar and setcdr). So part of the job of letf is to *change* the > cons cell upon exiting. The box is the same (and is what is returned), > but the content was changed at the moment the last closing paren of letf > is crossed. IOW: A good summary, IMHO. In LISP, lists are passed by reference. When a list is bound to a variable, the list is not copied. The value referenced by the variable will be the very same object. > The object is the same, but its content changed. Similar to : > (let ((foo (cons 'a 'b)) > (bar)) > (setq bar foo) ;; bar and foo have the same object in their value cell. > (setcdr foo 'c) ;; change the cdr of that cons cell > (eq bar foo)) ;; they're still the same. > => t > > > But that's not because outside the letf the object created > > inside it is necessarily gone. It's gone because letf doesn't return a > > pointer to it > > I guess it's not gone per se until the garbage collector does its > work. (a b c d) is garbage collected. The object equal to (KEY a b c d) inside letf is never destroyed or garbage collected, since this list is referenced by test-x and the return value of the function. But a part of the object has been changed (restored) by letf. Regards, Michael.