[Top][All Lists]

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

Re: address@hidden: The `cl-functions' byte compiler warning doesn't wor

From: Johan Bockgård
Subject: Re: address@hidden: The `cl-functions' byte compiler warning doesn't work]
Date: Wed, 13 Jun 2007 02:13:21 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1.50 (gnu/linux)

martin rudalics <address@hidden> writes:

> I've checked in a fix.  Please try.

The change is correct. However, I've found two further problems
in this function:

    (defun byte-compile-find-cl-functions ()
      (unless byte-compile-cl-functions
        (dolist (elt load-history)
          (when (and (stringp (car elt))
                      "^cl\\>" (file-name-nondirectory (car elt))))
            (setq byte-compile-cl-functions
                  (append byte-compile-cl-functions
                          (cdr elt)))))
        (let ((tail byte-compile-cl-functions))
          (while tail
            (if (and (consp (car tail))
                     (eq (car (car tail)) 'autoload))
                (setcar tail (cdr (car tail))))
            (setq tail (cdr tail))))))

1. It looks for `(autoload . FOO)' entries in load-history, but not
for `(defun . FOO)' (it wrongly assumes that functions are represented
by plain symbols).

2. It modifies load-history as a side-effect.

(And byte-compile-cl-functions contains useless non-function
(require/t/provide) entries)

This illustrates the problems:

    $ emacs -Q

    (require 'cl)

    (byte-compile (lambda () (subst nil nil nil)))
      => no warning

    (byte-compile (lambda () (subst-if nil nil nil)))
      => Warning: Function `subst-if' from cl package called at runtime

    ;; The `(autoload . CL-FUNCTION)' entries in `load-history' have
       been replaced by `CL-FUNCTION'.

In the first case, the (defun . subst) entry is not respected.

In the second case, the `(autoload . subst-if)' entry is found. This
is transformed into a symbol by `setcar'ing structure shared between
byte-compile-cl-functions and load-history.

This patch uses the `(defun . FOO)' entry format, and avoids modifying

--- bytecomp.el 13 Jun 2007 01:27:08 +0200      2.201
+++ bytecomp.el 13 Jun 2007 01:02:49 +0200      
@@ -1359,12 +1359,12 @@
                  "^cl\\>" (file-name-nondirectory (car elt))))
        (setq byte-compile-cl-functions
-             (append byte-compile-cl-functions
-                     (cdr elt)))))
+             (append (cdr elt)
+                     byte-compile-cl-functions))))
     (let ((tail byte-compile-cl-functions))
       (while tail
        (if (and (consp (car tail))
-                (eq (car (car tail)) 'autoload))
+                (memq (car (car tail)) '(autoload defun)))
            (setcar tail (cdr (car tail))))
        (setq tail (cdr tail))))))

Johan Bockgård

reply via email to

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