emacs-devel
[Top][All Lists]
Advanced

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

Re: Question about byte-compiler warning


From: Vinicius Jose Latorre
Subject: Re: Question about byte-compiler warning
Date: Tue, 25 Sep 2007 15:51:02 -0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4

Stefan Monnier wrote:
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.

Ok, but wasn't the construction:

(cond
  ((featurep 'xemacs)
    <xemacs-part> )
  (t
    <emacs-part> ))

recognized by the byte-compiler as a kind of conditional byte-compilation?


BTW, the byte-compiler gives no warning to the construction:

(eval-and-compile
  (cond
    ((featurep 'xemacs) <xemacs-part>)
    (t <emacs-part> ))))

It could also be used as an alternative construction.


Vinicius





reply via email to

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