GNU bug report logs -
#8140
byte-compiler to not warn about conditional defuns that are always defined
Previous Next
Reported by: sds <at> gnu.org
Date: Mon, 28 Feb 2011 15:17:01 UTC
Severity: wishlist
Merged with 20144
Found in versions 24.0.50, 25.0.50
Full log
Message #10 received at control <at> debbugs.gnu.org (full text, mbox):
severity 8140 wishlist
thanks
> the following code:
> (if (eval-when-compile (eq 'w32 window-system))
> (defun foo () ...) ; woe32 definition
> (defun foo () ...)) ; unix definition
> (defun bar () ... (foo) ... )
> results in this byte-compilation warning:
> In end of data:
> lib.el:2029:1:Warning: the function `foo' is not known to be defined.
> I think the warning is wrong because it should be pretty easy for the
> compiler to see that `foo' is always defined.
That's right. It's fairly easy to write a code that can decide which
functions are known to exist and which aren't. OTOH given the existing
bytecomp.el structure, it's not that easy to make it understand that in
the above code `foo' will always be defined. Of course, maybe there's
a clever way to do it, but at least for now it seems unlikely to happen.
So until it does happen I recommend you use
(defalias 'foo
(if blabla
(lambda () ...)
(lambda () ...)))
which makes it more obvious to the byte-compiler that `foo' will indeed
always be defined. The above form works well for single-function
definitions, but it's not as nice when doing
(cond
(toto
(defun foo1 ...)
(defun foo2 ...)
(defun foo3 ...))
(t
(defun foo1 ...)
(defun foo2 ...)
(defun foo3 ...)))
so it would indeed be good to teach the byte-compiler how to figure
these things out.
Stefan
This bug report was last modified 10 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.