all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How does letf work?
Date: Thu, 30 Jan 2014 00:46:42 +0100	[thread overview]
Message-ID: <87sis62vx9.fsf@web.de> (raw)
In-Reply-To: 87txcmq13g.fsf@yahoo.fr

Nicolas Richard <theonewiththeevillook@yahoo.fr> 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.




  reply	other threads:[~2014-01-29 23:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 23:10 How does letf work? Florian Beck
2014-01-29  2:23 ` Michael Heerdegen
     [not found] ` <mailman.13075.1390962244.10748.help-gnu-emacs@gnu.org>
2014-01-29  8:37   ` Joost Kremers
2014-01-29  9:14     ` Joost Kremers
2014-01-29 15:29       ` Florian Beck
2014-01-29 16:12         ` Nicolas Richard
2014-01-29 20:19           ` Florian Beck
2014-01-29 15:06     ` Nicolas Richard
2014-01-29 23:46       ` Michael Heerdegen [this message]
2014-01-29 23:53     ` Michael Heerdegen
     [not found] <mailman.13065.1390951154.10748.help-gnu-emacs@gnu.org>
2014-01-29  0:35 ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sis62vx9.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.