unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* weird byte compile message when using (when t ... )
@ 2021-02-12 13:12 Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-12 14:17 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-12 13:12 UTC (permalink / raw)
  To: help-gnu-emacs

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

  In toplevel form:
  ~/.emacs:169:7: Warning: assignment to free variable ‘show-paren-delay’

  In end of data:
  ~/.emacs:223:1: Warning: the following functions are not known to be defined:
      enable-line-mode, conf-space-mode-hook-f, text-mode-hook-f

When I remove the enclosure and compile everything again no
errors or warnings are reported.

[1] https://dataswamp.org/~incal/conf/.emacs

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: weird byte compile message when using (when t ... )
  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
  2021-02-12 14:35   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2021-02-12 14:17 UTC (permalink / raw)
  To: help-gnu-emacs

> 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




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

* Re: weird byte compile message when using (when t ... )
  2021-02-12 14:17 ` Stefan Monnier
@ 2021-02-12 14:35   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-12 14:35 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

> 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").

OK, king, thanks :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

end of thread, other threads:[~2021-02-12 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2021-02-12 14:35   ` Emanuel Berg via Users list for the GNU Emacs text editor

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).