unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8140: 24.0.50; wrong compilation warning
@ 2011-02-28 15:16 Sam Steingold
  2011-02-28 16:24 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Steingold @ 2011-02-28 15:16 UTC (permalink / raw)
  To: 8140

In GNU Emacs 24.0.50.6 (x86_64-unknown-linux-gnu, X toolkit)
 of 2011-02-28 on tbox
Windowing system distributor `Colin Harrison', version 11.0.60900031
configured using `configure  '--exec-prefix=/opt/emacs/lucid' '--prefix=/opt/emacs' '--with-x-toolkit=lucid''

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.

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) X
http://dhimmi.com http://truepeace.org http://www.PetitionOnline.com/tap12009/
http://mideasttruth.com http://ffii.org http://www.memritv.org
Even Windows doesn't suck, when you use Common Lisp





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#8140: 24.0.50; wrong compilation warning
  2011-02-28 15:16 bug#8140: 24.0.50; wrong compilation warning Sam Steingold
@ 2011-02-28 16:24 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2011-02-28 16:24 UTC (permalink / raw)
  To: 8140

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-28 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-28 15:16 bug#8140: 24.0.50; wrong compilation warning Sam Steingold
2011-02-28 16:24 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).