help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: weird byte compile message when using (when t ... )


From: Stefan Monnier
Subject: Re: weird byte compile message when using (when t ... )
Date: Fri, 12 Feb 2021 09:17:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> When I enclose .emacs [1] in (when t ... ) or
> (if t (progn ... )) the following what I can see (?) incorrect
> warnings are reported

The byte-compiler treats code differently if it's a "toplevel" or not
(where "toplevel" either literally means "not nested inside anything
else" or "nested inside a `progn` (or something that expands to one)
that is a toplevel").

E.g. of things this affect:
- a function definition that's not at toplevel will not be considered
  as defined when compiling the current file.
- a `require` that's not at toplevel will not be executed during compile time.
- a `defmacro` that's not at toplevel will not be available for
  expansion of macros within the same file.
- ...

So that can make big differences to warnings (and more).  This can be
used on purpose, of course, such as using `(if t (require 'foo))` to
make sure `foo` is only required when the file is loaded, so that
compilation of the file will not fail just because `foo` is missing.


        Stefan




reply via email to

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