emacs-devel
[Top][All Lists]
Advanced

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

Re: cl-loop's "with" destructuring-bind looks broken


From: Stefan Monnier
Subject: Re: cl-loop's "with" destructuring-bind looks broken
Date: Mon, 21 Apr 2014 17:18:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

>> I have faced an issue on 24.3.90.2 when using my extension that
>> includes an expression like:
>> (cl-loop with (a b c) = '(1 2 3) return (+ a b c))
> It should be fixed now.

Only in `trunk', tho.

> I'd appreciate if Stefan took a look at the fix, trunk revision
> 117000.  I don't know why that (eq body 'setq) test was there in the
> first place, but removing it doesn't seem to break anything.

I installed the patch below in emacs-24, which is a bit more careful
(your patch ends up let-binding variables redundantly, and it renames
vars in cases where it's not necessary).


        Stefan


=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- lisp/emacs-lisp/cl-macs.el  2014-03-24 20:41:08 +0000
+++ lisp/emacs-lisp/cl-macs.el  2014-04-21 21:09:22 +0000
@@ -1542,12 +1542,14 @@
               (if (and (cl--unused-var-p temp) (null expr))
                   nil ;; Don't bother declaring/setting `temp' since it won't
                      ;; be used when `expr' is nil, anyway.
-                (when (and (eq body 'setq) (cl--unused-var-p temp))
+                (when (or (null temp)
+                          (and (eq body 'setq) (cl--unused-var-p temp)))
                   ;; Prefer a fresh uninterned symbol over "_to", to avoid
                   ;; warnings that we set an unused variable.
                   (setq temp (make-symbol "--cl-var--"))
                   ;; Make sure this temp variable is locally declared.
-                  (push (list (list temp)) cl--loop-bindings))
+                  (when (eq body 'setq)
+                    (push (list (list temp)) cl--loop-bindings)))
                 (push (list temp expr) new))
               (while (consp spec)
                 (push (list (pop spec)





reply via email to

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