From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Florian Beck <fb@miszellen.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How does letf work?
Date: Wed, 29 Jan 2014 17:12:48 +0100 [thread overview]
Message-ID: <877g9ihim7.fsf@yahoo.fr> (raw)
In-Reply-To: <52E91E74.8060204@miszellen.de> (Florian Beck's message of "Wed, 29 Jan 2014 16:29:56 +0100")
Florian Beck <fb@miszellen.de> 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.
next prev parent reply other threads:[~2014-01-29 16:12 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 [this message]
2014-01-29 20:19 ` Florian Beck
2014-01-29 15:06 ` Nicolas Richard
2014-01-29 23:46 ` Michael Heerdegen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877g9ihim7.fsf@yahoo.fr \
--to=theonewiththeevillook@yahoo.fr \
--cc=fb@miszellen.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).