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: Emanuel Berg
Subject: Re: eval-when-compile and require
Date: Tue, 21 Nov 2017 17:55:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

t wrote:

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

Actually that is quite common with all the
CL macros. And I've never had any warnings or
problem with those.

One example is

    cl-incf is a Lisp macro in `cl-lib.el'.

Here is another situation

    cl-caddr is a compiled Lisp function in
    `cl-lib.el'.

    (cl-caddr X)

    This function has a compiler macro
    `cl--compiler-macro-cXXr'.

What does it mean the "function has a compiler
macro"?

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

OK, not familiar with that situation...

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

Likewise...

>> 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?

With `eval-when-compile', if it does what it
says, and without compilation, won't the
definitions be void with the `require'
never being reached?

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

Well, sometimes not even that!
Possible explanation interference from other
files being compiled, or being in a compiled
state, that are required from the file...

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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