From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: weird byte compile message when using (when t ... )
Date: Fri, 12 Feb 2021 09:17:50 -0500 [thread overview]
Message-ID: <jwvk0rdfl2g.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 87tuqhbfbh.fsf@zoho.eu
> 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
next prev parent reply other threads:[~2021-02-12 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-12 13:12 weird byte compile message when using (when t ... ) Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-12 14:17 ` Stefan Monnier [this message]
2021-02-12 14:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvk0rdfl2g.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).