From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: cl-loop's "with" destructuring-bind looks broken Date: Mon, 21 Apr 2014 17:18:19 -0400 Message-ID: References: <87sip8o94g.wl%tomo@cx4a.org> <53546F19.2050604@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398115134 1055 80.91.229.3 (21 Apr 2014 21:18:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2014 21:18:54 +0000 (UTC) Cc: Tomohiro Matsuyama , emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 21 23:18:47 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WcLby-0004i1-OV for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2014 23:18:46 +0200 Original-Received: from localhost ([::1]:51639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcLby-0001PK-AA for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2014 17:18:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcLbp-0001Oh-Gn for emacs-devel@gnu.org; Mon, 21 Apr 2014 17:18:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcLbi-0004dK-28 for emacs-devel@gnu.org; Mon, 21 Apr 2014 17:18:37 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:40666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcLbh-0004bi-SM for emacs-devel@gnu.org; Mon, 21 Apr 2014 17:18:29 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s3LLIJI9015152; Mon, 21 Apr 2014 17:18:20 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B2BCF600CA; Mon, 21 Apr 2014 17:18:19 -0400 (EDT) In-Reply-To: <53546F19.2050604@dancol.org> (Daniel Colascione's message of "Sun, 20 Apr 2014 18:06:33 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4919=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4919> : inlines <751> : streams <1164203> : uri <1736683> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:171545 Archived-At: >> 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)