all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Daniel Colascione <dancol@dancol.org>
Cc: Tomohiro Matsuyama <tomo@cx4a.org>, emacs-devel@gnu.org
Subject: Re: cl-loop's "with" destructuring-bind looks broken
Date: Mon, 21 Apr 2014 17:18:19 -0400	[thread overview]
Message-ID: <jwvha5mpg4o.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <53546F19.2050604@dancol.org> (Daniel Colascione's message of "Sun, 20 Apr 2014 18:06:33 -0700")

>> 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	other threads:[~2014-04-21 21:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-20  5:36 cl-loop's "with" destructuring-bind looks broken Tomohiro Matsuyama
2014-04-21  1:06 ` Daniel Colascione
2014-04-21 21:18   ` Stefan Monnier [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvha5mpg4o.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    --cc=tomo@cx4a.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.