unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: eval-when-compile and require
Date: Tue, 21 Nov 2017 08:29:13 +0100	[thread overview]
Message-ID: <20171121072913.GA11830@tuxteam.de> (raw)
In-Reply-To: <86o9nwwa37.fsf@zoho.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Nov 21, 2017 at 05:05:00AM +0100, Emanuel Berg wrote:
> I'm reading on with the intention of preparing
> the pack for MELPA and now it says [1]
> 
>     If you use many functions and variables
>     from a certain file, you can add
>     a ‘require’ for that package to avoid
>     compilation warnings for them.
>     For instance,
> 
>               (eval-when-compile
>                 (require 'foo))
> 

You use this when you require foo's services at compile
time.

The most common case would be that you require macro
definitions from foo: there, (require 'foo) would
arrive too late. The compiler is the one which has to
expand the macros, so their definitions are needed
during the compile phase.

Another example would be to do some pre-calculation
you don't want to repeat at run time (because it takes
too long, or because you want to make sure that its
results stay stable)

Note that when you need something *both* at compile
and at run time, eval-and-compile is your friend.

> Here I'm not following. Of course the stuff
> should be compiled. And if it isn't, the above
> enclosement with `eval-when-compile' helps
> by... breaking it?

Hm. What gets broken?

> Besides there are no warnings with plain
> `require', so what does it all mean?

Then you don't seem to need whatever foo provides at
compile time => you only need a plain "require".

That's fine.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAloT1ckACgkQBcgs9XrR2kaHOwCdGSbPVY3IR97Fh3mgZGtUHerp
EKoAnR9sUKSjcyN8XZLzF8ZVh00932kq
=YRdU
-----END PGP SIGNATURE-----



  reply	other threads:[~2017-11-21  7:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  4:05 eval-when-compile and require Emanuel Berg
2017-11-21  7:29 ` tomas [this message]
2017-11-21 16:55   ` Emanuel Berg
2017-11-22  2:42 ` Stefan Monnier
2017-11-22 14:03   ` Emanuel Berg
2017-11-23  5:25   ` Emanuel Berg
2017-11-27  2:51   ` Emanuel Berg
     [not found] ` <mailman.4288.1511318543.27995.help-gnu-emacs@gnu.org>
2017-11-23  5:22   ` Emanuel Berg

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=20171121072913.GA11830@tuxteam.de \
    --to=tomas@tuxteam.de \
    --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).