all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6750: Byte compiler: spurious message "cl used at runtime"
@ 2010-07-28 18:15 Alan Mackenzie
  2010-07-28 23:01 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Mackenzie @ 2010-07-28 18:15 UTC (permalink / raw)
  To: 6750

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).





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6750: Byte compiler: spurious message "cl used at runtime"
  2010-07-28 18:15 bug#6750: Byte compiler: spurious message "cl used at runtime" Alan Mackenzie
@ 2010-07-28 23:01 ` Stefan Monnier
  2010-07-29 19:03   ` Alan Mackenzie
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-07-28 23:01 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 6750

> 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







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6750: Byte compiler: spurious message "cl used at runtime"
  2010-07-28 23:01 ` Stefan Monnier
@ 2010-07-29 19:03   ` Alan Mackenzie
  2010-07-29 19:51     ` Juanma Barranquero
  2010-07-30  9:18     ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Mackenzie @ 2010-07-29 19:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6750

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).





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6750: Byte compiler: spurious message "cl used at runtime"
  2010-07-29 19:03   ` Alan Mackenzie
@ 2010-07-29 19:51     ` Juanma Barranquero
  2010-07-30  9:18     ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Juanma Barranquero @ 2010-07-29 19:51 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 6750

On Thu, Jul 29, 2010 at 21:03, Alan Mackenzie <acm@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6750: Byte compiler: spurious message "cl used at runtime"
  2010-07-29 19:03   ` Alan Mackenzie
  2010-07-29 19:51     ` Juanma Barranquero
@ 2010-07-30  9:18     ` Stefan Monnier
  2011-07-14 13:28       ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-07-30  9:18 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 6750

>> 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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6750: Byte compiler: spurious message "cl used at runtime"
  2010-07-30  9:18     ` Stefan Monnier
@ 2011-07-14 13:28       ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-14 13:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6750, Alan Mackenzie

Stefan Monnier <monnier@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/





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-14 13:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-28 18:15 bug#6750: Byte compiler: spurious message "cl used at runtime" Alan Mackenzie
2010-07-28 23:01 ` Stefan Monnier
2010-07-29 19:03   ` Alan Mackenzie
2010-07-29 19:51     ` Juanma Barranquero
2010-07-30  9:18     ` Stefan Monnier
2011-07-14 13:28       ` Lars Magne Ingebrigtsen

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.