GNU bug report logs - #6750
Byte compiler: spurious message "cl used at runtime"

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Wed, 28 Jul 2010 18:05:02 UTC

Severity: minor

Tags: notabug

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6750 in the body.
You can then email your comments to 6750 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Wed, 28 Jul 2010 18:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alan Mackenzie <acm <at> muc.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 28 Jul 2010 18:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Byte compiler: spurious message "cl used at runtime"
Date: Wed, 28 Jul 2010 18:15:53 +0000
Hi, Emacs,

In this macro declaration:

    (defmacro c-declare-lang-variables ()
      `(progn
         ,@(mapcan (lambda (init)
                     `(,(if (elt init 2)
                            `(defvar ,(car init) nil ,(elt init 2))
                          `(defvar ,(car init) nil))
                       (make-variable-buffer-local ',(car init))))
                   (cdr c-lang-variable-inits))))

, (from cc-engine.el), the byte-compiler gives this warning:

    "Function `mapcan' from cl package called at runtime".

It is clear that the mapcan, being within a ,@ construct, does its work
at macro-expansion time, i.e. compile time.

Thus the warning message is wrong.  This is a bug.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Wed, 28 Jul 2010 23:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 6750 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6750 <at> debbugs.gnu.org
Subject: Re: bug#6750: Byte compiler: spurious message "cl used at runtime"
Date: Thu, 29 Jul 2010 01:01:46 +0200
> In this macro declaration:

>     (defmacro c-declare-lang-variables ()
>       `(progn
>          ,@(mapcan (lambda (init)
>                      `(,(if (elt init 2)
>                             `(defvar ,(car init) nil ,(elt init 2))
>                           `(defvar ,(car init) nil))
>                        (make-variable-buffer-local ',(car init))))
>                    (cdr c-lang-variable-inits))))

> , (from cc-engine.el), the byte-compiler gives this warning:

>     "Function `mapcan' from cl package called at runtime".

> It is clear that the mapcan, being within a ,@ construct, does its work
> at macro-expansion time, i.e. compile time.

> Thus the warning message is wrong.  This is a bug.

This macro will be in the .elc.  This means it can be called "at run
time" (e.g. if you do M-: (c-declare-lang-variables ...) RET).


        Stefan






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Thu, 29 Jul 2010 18:52:01 GMT) Full text and rfc822 format available.

Message #11 received at 6750 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6750 <at> debbugs.gnu.org
Subject: Re: bug#6750: Byte compiler: spurious message "cl used at runtime"
Date: Thu, 29 Jul 2010 19:03:06 +0000
Hi, Stefan,

On Thu, Jul 29, 2010 at 01:01:46AM +0200, Stefan Monnier wrote:
> > In this macro declaration:

> >     (defmacro c-declare-lang-variables ()
> >       `(progn
> >          ,@(mapcan (lambda (init)
> >                      `(,(if (elt init 2)
> >                             `(defvar ,(car init) nil ,(elt init 2))
> >                           `(defvar ,(car init) nil))
> >                        (make-variable-buffer-local ',(car init))))
> >                    (cdr c-lang-variable-inits))))

> > , (from cc-engine.el), the byte-compiler gives this warning:

> >     "Function `mapcan' from cl package called at runtime".

> > It is clear that the mapcan, being within a ,@ construct, does its work
> > at macro-expansion time, i.e. compile time.

> > Thus the warning message is wrong.  This is a bug.

> This macro will be in the .elc.  This means it can be called "at run
> time" (e.g. if you do M-: (c-declare-lang-variables ...) RET).

That brought a smile to my face.  It's pure sophistry. :-)  With no more
creativity than you've just shown, ANY use of mapcan could be "shown" to
be "use at runtime".  So why not shorten the warning message to

    "Function `mapcan' from cl package was used"
    
?  ;-)

Or, perhaps you could indulge me a little, and show an example of mapcan
(or some other cl function) which isn't "use at runtime".  You know as
well as I do, that there's no rigid separation of Lisp into compilation
and running phases.

I put it to you that that error message is not, in general, helpful.  I
think it should be restricted to uses of mapcan at runtime (in a defun)
or when it's in the form generated by a macro.

I'm trying to get rid of warnings messages in CC Mode.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Thu, 29 Jul 2010 19:52:01 GMT) Full text and rfc822 format available.

Message #14 received at 6750 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6750 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6750: Byte compiler: spurious message "cl used at runtime"
Date: Thu, 29 Jul 2010 21:51:28 +0200
On Thu, Jul 29, 2010 at 21:03, Alan Mackenzie <acm <at> muc.de> wrote:

> Or, perhaps you could indulge me a little, and show an example of mapcan
> (or some other cl function) which isn't "use at runtime".

;; at top level
(eval-when-compile
   (mapcan ...))

> I put it to you that that error message is not, in general, helpful.  I
> think it should be restricted to uses of mapcan at runtime (in a defun)
> or when it's in the form generated by a macro.

But the point is that the macro could be called at runtime and
`mapcan' would not be defined.

Try byte-compiling test.el:
--------------------------------------------------------------------------------
(eval-when-compile (require 'cl))

(defmacro mapcan-at-runtime ()
  `(setq sample ',(mapcan 'identity '((a) (b) (c)))))
--------------------------------------------------------------------------------

(which produces the warning), and then

emacs -Q -l test.elc
M-: (mapcan-at-runtime) <RET>

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Fri, 30 Jul 2010 09:18:02 GMT) Full text and rfc822 format available.

Message #17 received at 6750 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6750 <at> debbugs.gnu.org
Subject: Re: bug#6750: Byte compiler: spurious message "cl used at runtime"
Date: Fri, 30 Jul 2010 11:18:05 +0200
>> This macro will be in the .elc.  This means it can be called "at run
>> time" (e.g. if you do M-: (c-declare-lang-variables ...) RET).
> That brought a smile to my face.  It's pure sophistry. :-)

Except that this is not the reason I put the warning, but the reason why
the byte-compiler's code thinks the warning is warranted.
The byte-compiler is fairly stupid and doesn't know that this macro is
not intended to be used at runtime.

I agree it's not great, and it leads to "spurious" warnings like that.
Suggestions (and patches even better) welcome to try and resolve
the problem.


        Stefan




Added tag(s) notabug. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 14 Jul 2011 13:30:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 6750 <at> debbugs.gnu.org and Alan Mackenzie <acm <at> muc.de> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 14 Jul 2011 13:30:03 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6750; Package emacs. (Thu, 14 Jul 2011 14:03:04 GMT) Full text and rfc822 format available.

Message #24 received at 6750 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6750 <at> debbugs.gnu.org, Alan Mackenzie <acm <at> muc.de>
Subject: Re: bug#6750: Byte compiler: spurious message "cl used at runtime"
Date: Thu, 14 Jul 2011 15:28:39 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> The byte-compiler is fairly stupid and doesn't know that this macro is
> not intended to be used at runtime.

The macro, however, is in the .elc file, so I don't think this is a
bug.  (Although the warning could be changed to, perhaps, "cl in the
.elc file" or something.)

Anyway, I'm closing the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Aug 2011 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 316 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.