Is eval-when-compile a special form (primitive in C), or a macro?

According to the elisp manual, C-h S eval-when-compile RET,

Special Form: eval-when-compile body...

But according to C-h f eval-when-compile RET,

eval-when-compile is a Lisp macro in ‘byte-run.el’

I'm trying to understand the difference between eval-when-compile and eval-and-compile. They have identical macro definitions in byte-run.el, but since the manual says they're special forms, rather than macros, I suspect there's something I'm missing.

1 Answer 1


It's a macro defined in byte-run.el:

(defmacro eval-when-compile (&rest body)
  "Like `progn', but evaluates the body at compile time if you're compiling.
Thus, the result of the body appears to the compiler as a quoted
constant.  In interpreted code, this is entirely equivalent to
`progn', except that the value of the expression may be (but is
not necessarily) computed at load time if eager macro expansion
is enabled."
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

I've submitted (doc) bug #47862 for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.