GNU bug report logs -
#27177
26.0.50: Macroexpanding cl-loop and friends (make-symbol usage)
Previous Next
Reported by: Alex <agrambot <at> gmail.com>
Date: Wed, 31 May 2017 23:25:02 UTC
Severity: minor
Found in version 26.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Consider the following simple cl-loop form:
(cl-loop for x in '(1 2 3)
for y in '(a b c)
collect (list x y))
The macroexpanded result is:
(cl-block nil
(let*
((--cl-var--
'(1 2 3))
(x nil)
(--cl-var--
'(a b c))
(y nil)
(--cl-var-- nil))
(while
(and
(consp --cl-var--)
(progn
(setq x
(car --cl-var--))
(consp --cl-var--)))
(setq y
(car --cl-var--))
(push
(list x y)
--cl-var--)
(setq --cl-var--
(cdr --cl-var--))
(setq --cl-var--
(cdr --cl-var--)))
(nreverse --cl-var--)))
It's easy to verify that this expansion doesn't do the same job by
noticing that the macroexpanded form always returns nil.
Note that in Common Lisp (at least in SBCL), macroexpanding and then
evaluating the result works as expected.
This is because cl-macs.el uses make-symbol instead of gensym, like SBCL
does.
Should cl-loop and friends use cl-gensym? One possible disadvantage to
that approach is that since Emacs Lisp lacks CL's bignums, it could lead
to some issues past most-positive-fixnum.
The reason I reported this is actually because I found it difficult to
debug macroexpanded cl-loop forms when all of the uninterned symbols had
the same representation. Using cl-gensym would help with debugging.
This bug report was last modified 4 years and 351 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.