feat(lib): add eval-when-compile! macro

Unlike eval-when-compile, the body of this macro's calls will only be
evaluated while byte-compiling.
This commit is contained in:
Henrik Lissner 2022-09-06 21:25:25 +02:00
parent 0100b08402
commit 4009509db5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -286,6 +286,14 @@ See `eval-if!' for details on this macro's purpose."
(when (eval cond) (when (eval cond)
(macroexp-progn body))) (macroexp-progn body)))
(defmacro eval-when-compile! (&rest body)
"Evaluate BODY *only* during byte-compilation.
Unlike `eval-when-compile', which is equivalent to `progn' in interpreted code,
this macro's BODY will only be evaluated during byte-compilation."
(declare (indent 0))
(when (bound-and-true-p byte-compile-current-file)
(ignore (eval (macroexp-progn body) t))))
;;; Closure factories ;;; Closure factories
(defmacro lambda! (arglist &rest body) (defmacro lambda! (arglist &rest body)