From: Helmut Eller <eller.helmut@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Replacement for Common Lisp's GENSYM in Emacs Lisp
Date: Mon, 08 Mar 2010 08:01:15 +0100 [thread overview]
Message-ID: <m2lje3e1qc.fsf@gmail.com> (raw)
In-Reply-To: jwvaaujjtwf.fsf-monnier+gnu.emacs.help@gnu.org
* Stefan Monnier [2010-03-08 05:55+0100] writes:
>>> (defmacro dotimes (xl e)
>>> (let ((x (car xl))
>>> (l (cadr xl)))
>>> `(let ((body (lambda (,x) ,e))
>>> (list ,l))
>>> (while (consp list)
>>> (funcall body (car list))
>>> (setq list (cdr list))))))
>>>
>>> Notice how the expressions `l' and `e' are evaluated in a context where
>>> neither of `body', nor `list' exist. No need for gensym.
>
>> What makes you think that body and list aren't bound in e?
>
> Nothing, but luckily it doesn't make any difference whether they are
> or not.
Your "dotimes" macro produces:
(let ((list '(1)) (result ()))
(dotimes (i '(1 2 3)) (push list result))
result) => ((3) (2 3) (1 2 3))
While a version which doesn't shadow "list" produces this:
(let ((list '(1)) (result ()))
(dolist (i '(1 2 3)) (push list result))
result) => ((1) (1) (1))
Helmut
next prev parent reply other threads:[~2010-03-08 7:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2359.1267888813.14305.help-gnu-emacs@gnu.org>
2010-03-06 16:10 ` Replacement for Common Lisp's GENSYM in Emacs Lisp David Kastrup
2010-03-06 16:35 ` Teemu Likonen
2010-03-07 7:07 ` Tim X
2010-03-07 19:06 ` Stefan Monnier
2010-03-07 22:07 ` Helmut Eller
2010-03-08 4:55 ` Stefan Monnier
2010-03-08 7:01 ` Helmut Eller [this message]
2010-03-09 2:33 ` Stefan Monnier
2010-03-06 15:19 Teemu Likonen
2010-03-07 5:48 ` tomas
2010-03-07 6:13 ` Teemu Likonen
[not found] ` <mailman.2390.1267942438.14305.help-gnu-emacs@gnu.org>
2010-03-11 22:48 ` Pascal J. Bourguignon
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=m2lje3e1qc.fsf@gmail.com \
--to=eller.helmut@gmail.com \
--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).