From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: false warnings when compiling with lexical-binding and cl-lib.
Date: Sat, 23 Nov 2013 17:24:10 +0100 [thread overview]
Message-ID: <878uwfulw5.fsf@gmail.com> (raw)
In-Reply-To: 87d2lrunbg.fsf@gmail.com
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> This patch avoid adding a new binding by the 'into' clause when the
>>> binding have been already added by a 'with' clause.
>>> I wonder if this is correct, real common-lisp return an error in such
>>> case, WDYT?
>>
>> Oh, wait, then the warning is OK. It indicates that the `with lst' is
>> extraneous and unused. IOW, there's no bug to fix. We could change
>> cl-loop to signal an error, but it doesn't seem to be worth the trouble.
>
> Yes, maybe the error message can be a little more explicit, common-lisp send a
> message like this:
>
> ,----
> | Variable LST in INTO clause is a duplicate
> | current LOOP context: COLLECT I INTO LST FINALLY.
> | [Condition of type SB-INT:COMPILED-PROGRAM-ERROR]
> `----
>
> Also the warning is only at compile time, should we return an error on
> evaluation ?
> This can be detected and handled from the same function
> i.e (cl--loop-handle-accum)
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 2209297..3faf23b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1564,9 +1564,13 @@ If BODY is `setq', then use SPECS for assignments rather than for bindings."
(defun cl--loop-handle-accum (def &optional func) ; uses loop-*
(if (eq (car cl--loop-args) 'into)
- (let ((var (cl--pop2 cl--loop-args)))
+ (let* ((var (cl--pop2 cl--loop-args))
+ (binding (list (list var def))))
(or (memq var cl--loop-accum-vars)
- (progn (push (list (list var def)) cl--loop-bindings)
+ (cl-assert (not (member binding cl--loop-bindings))
+ nil "Variable %s in INTO clause is a duplicate"
+ (upcase (symbol-name (caar binding))))
+ (progn (push binding cl--loop-bindings)
(push var cl--loop-accum-vars)))
var)
(or cl--loop-accum-var
--8<---------------cut here---------------end--------------->8---
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2013-11-23 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 15:29 false warnings when compiling with lexical-binding and cl-lib Thierry Volpiatto
2013-11-22 1:19 ` Stefan Monnier
2013-11-22 5:33 ` Thierry Volpiatto
2013-11-22 7:48 ` Thierry Volpiatto
2013-11-23 6:13 ` Thierry Volpiatto
2013-11-23 13:51 ` Stefan Monnier
2013-11-23 15:53 ` Thierry Volpiatto
2013-11-23 16:24 ` Thierry Volpiatto [this message]
2013-11-24 18:08 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878uwfulw5.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).