From: Florian Beck <fb@miszellen.de>
To: help-gnu-emacs@gnu.org
Cc: help-gnu-emacs@gnu.org
Subject: Re: How does letf work?
Date: Wed, 29 Jan 2014 21:19:39 +0100 [thread overview]
Message-ID: <52E9625B.80207@miszellen.de> (raw)
In-Reply-To: <877g9ihim7.fsf@yahoo.fr>
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
next prev parent reply other threads:[~2014-01-29 20:19 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 [this message]
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=52E9625B.80207@miszellen.de \
--to=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).