[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about byte-compiler warning
From: |
Stefan Monnier |
Subject: |
Re: Question about byte-compiler warning |
Date: |
Tue, 25 Sep 2007 13:13:56 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) |
> Create a test file like:
> test.el:
> ========
> (cond
> ((featurep 'xemacs)
> (defun bar ()
> (message "bar XEmacs"))
> (defun foo ()
> (bar)))
> (t
> (defun bar ()
> (message "bar Emacs"))
> (defun foo ()
> (bar))))
> (defun foobar ()
> (interactive)
> (foo))
> ========
> Now byte-compile the file above.
> The byte-compiler gives the following warning:
> In end of data:
> test.el:17:1:Warning: the following functions are not known to be
> defined:
> bar, foo
> But aren't these functions (bar and foo) defined using cond construct?
> Why does the byte-compiler give this warning?
The byte-compiler only considers as defined a function which is trivially
obviously defined without having to do any kind of analysis. I.e. it
doesn't look inside conditionals (or even inside `let's) to figure out what
might be defined in there.
A workaround I use sometimes is
(defalias 'foo
(if <toto>
(lambda (bla) bli)
(lambda (blo) blu)))
When the condition <toto> is used for several functions, this is a bit
inconvenient, tho.
Stefan