From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How does letf work?
Date: Wed, 29 Jan 2014 03:23:35 +0100 [thread overview]
Message-ID: <874n4nedaw.fsf@web.de> (raw)
In-Reply-To: 52E838C8.5020101@miszellen.de
Florian Beck <fb@miszellen.de> writes:
> (letf (((cdr test-x) '(a b c d)))
> test-x)
>
> = > (KEY 1 2 3 4)
Though paradoxical, it seems right to me. You return a list that you
modified temporarily, but when the result is printed in the echo area,
the letf has been left and the structure of the list has changed back.
Note that the variable test-x is not shadowed by your letf:
(let ((test-x-before test-x))
(letf (((cdr test-x) '(a b c d)))
(eq test-x test-x-before)))
==> t
But it has the expected value at that "point of time":
(letf (((cdr test-x) '(a b c d)))
(message "%s" test-x))
"(KEY a b c d)"
Here is a similarly paradoxical example without letf:
(setq test-x '(KEY 1 2 3 4))
(let ((old-cdr (cdr test-x)))
(prog2
(setf (cdr test-x) '(a b c d))
test-x ;returned value
(setf (cdr test-x) old-cdr)))
==> (KEY 1 2 3 4)
Regards,
Michael.
next prev parent reply other threads:[~2014-01-29 2:23 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 [this message]
[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
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=874n4nedaw.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.