* A question about macro bindings in cl-lib
@ 2013-04-24 8:17 Xue Fuqiao
2013-04-24 8:56 ` Stephen Berman
2013-04-24 13:33 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Xue Fuqiao @ 2013-04-24 8:17 UTC (permalink / raw)
To: help-gnu-emacs
In (info "(cl) Macro Bindings"):
(cl-defmacro my-dolist ((x list) &rest body)
(let ((var (cl-gensym)))
(list 'cl-loop 'for var 'on list 'do
(cl-list* 'cl-symbol-macrolet
(list (list x (list 'car var)))
body))))
(setq mylist '(1 2 3 4))
(my-dolist (x mylist) (cl-incf x))
mylist
=> (2 3 4 5)
The `my-dolist' call shown here expands to
(cl-loop for G1234 on mylist do
(cl-symbol-macrolet ((x (car G1234)))
(cl-incf x)))
I understand what this macro does, but what does "G1234" mean here? (I
have searched the archives, but "No document matching your query".)
--
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A question about macro bindings in cl-lib
2013-04-24 8:17 A question about macro bindings in cl-lib Xue Fuqiao
@ 2013-04-24 8:56 ` Stephen Berman
2013-04-24 13:33 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2013-04-24 8:56 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, 24 Apr 2013 16:17:42 +0800 Xue Fuqiao <xfq.free@gmail.com> wrote:
> In (info "(cl) Macro Bindings"):
>
> (cl-defmacro my-dolist ((x list) &rest body)
> (let ((var (cl-gensym)))
> (list 'cl-loop 'for var 'on list 'do
> (cl-list* 'cl-symbol-macrolet
> (list (list x (list 'car var)))
> body))))
> (setq mylist '(1 2 3 4))
> (my-dolist (x mylist) (cl-incf x))
> mylist
> => (2 3 4 5)
>
> The `my-dolist' call shown here expands to
>
> (cl-loop for G1234 on mylist do
> (cl-symbol-macrolet ((x (car G1234)))
> (cl-incf x)))
>
> I understand what this macro does, but what does "G1234" mean here?
Does the doc string of cl-gensym answer the question for you? If not,
can you make the question more specific?
Steve Berman
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A question about macro bindings in cl-lib
2013-04-24 8:17 A question about macro bindings in cl-lib Xue Fuqiao
2013-04-24 8:56 ` Stephen Berman
@ 2013-04-24 13:33 ` Stefan Monnier
2013-04-24 22:23 ` Xue Fuqiao
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-04-24 13:33 UTC (permalink / raw)
To: help-gnu-emacs
> I understand what this macro does, but what does "G1234" mean here?
Nothing, it's a variable whose name was "chosen" by code rather than by
a human.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-24 22:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-24 8:17 A question about macro bindings in cl-lib Xue Fuqiao
2013-04-24 8:56 ` Stephen Berman
2013-04-24 13:33 ` Stefan Monnier
2013-04-24 22:23 ` Xue Fuqiao
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).