bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27177: 26.0.50: Macroexpanding cl-loop and friends (make-symbol usag


From: Alex
Subject: bug#27177: 26.0.50: Macroexpanding cl-loop and friends (make-symbol usage)
Date: Wed, 31 May 2017 17:23:37 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]