emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Byte compiler and eval-when-compile


From: David Engster
Subject: Byte compiler and eval-when-compile
Date: Mon, 15 Oct 2012 18:23:08 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux)

Somehow the byte compiler got smart during the last days (I think it's
the change in rev. 110510). I now get a lot more 'function X might not
be defined at runtime' warnings than before. The reason seems to be that
it better checks if `eval-when-compile' was used properly. Which is fine
and all, but I now have the following problem:

In CEDET, we often use `require' statements in function bodies, like
this:

(defun test()
  (require 'eldoc)
  (message "%s" (eldoc-function-argstring '("foo" "bar"))))

The reason is simply to only do the require when it is actually needed,
so that startup time is reduced. Still, if you byte-compile the above,
you'll get a 'might not be defined at runtime' warning for
`eldoc-function-argstring'. I used to circumvent that problem by simply
doing

(eval-when-compile
  (require 'eldoc))

Before you scream at me: I *know* this is not what `eval-when-compile'
is for, but it has worked until a few days ago. It seems the
byte-compiler now sees that I'm actually using a function from eldoc,
but he still doesn't see that I'm requiring the package it in the
function body. Do I now really have to use `declare-function' for all
those cases?

-David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]