emacs-devel
[Top][All Lists]
Advanced

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

[Bug] (defun foo) during compilation defines `foo' as 0-arg `igno re'


From: Wedler, Christoph
Subject: [Bug] (defun foo) during compilation defines `foo' as 0-arg `igno re'
Date: Mon, 7 Apr 2003 19:27:11 +0200

[Test using Emacs-21.2.95.1.]

If you evaluate (defun foo), you get the error
   (wrong-number-of-arguments #<subr defun> 1)

If you like to have your .el files compiled without warnings, you might
want to use above form just like you could use (defvar foo).  OK, let's
write the file bar.el:

    (eval-when-compile
      (defun foo))

    (defun bar ()
      (if (fboundp 'foo) (foo))  ; or more complicated 
      (message "bar"))

Using M-x byte-compile-file RET bar.el RET now doesn't produce any
warnings.  At first, you think, "hey, this is great", but then you
realize, it's not so:

 1. If you call (foo 2) instead (foo), you get the warning

    While compiling bar:
      ** foo called with 1 argument, but accepts only 0

 2. After the compilation, evaluating (fboundp 'foo) returns t, and
    `foo' is defined as a 0-arg function which returns nil.

While 1 is just annoying, 2 is really bad: if a package uses (defun
foo), it must now mention in INSTALL s/th like "exit and restart Emacs
after any compilation of the .el files".  If (defun foo) would simply
signal an error, we could use (ignore-errors (defun foo)) in the hope
that a future Emacs would define a useful semantics for (defun foo),
i.e., just like for (defvar foo).

- Christoph




reply via email to

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