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

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

Re: eval-when-compile and require


From: tomas
Subject: Re: eval-when-compile and require
Date: Tue, 21 Nov 2017 08:29:13 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----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 via email to

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