Skip to main content
Became Hot Network Question
Fix tags; improve formatting
Source Link
Basil
  • 12.6k
  • 44
  • 70

How can eval-when-compile and eval-and-compile have different behavior if their definitions are identical?

From byte-run.el:

(defmacro eval-when-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

(defmacro eval-and-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))
(defmacro eval-when-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

(defmacro eval-and-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

How can eval-when-compile and eval-and-compile have different behavior if their definitions are identical?

From byte-run.el:

(defmacro eval-when-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

(defmacro eval-and-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

How can eval-when-compile and eval-and-compile have different behavior if their definitions are identical?

From byte-run.el:

(defmacro eval-when-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

(defmacro eval-and-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))
Source Link
ivan
  • 2k
  • 11
  • 20

eval-when-compile and eval-and-compile identical definitions?

How can eval-when-compile and eval-and-compile have different behavior if their definitions are identical?

From byte-run.el:

(defmacro eval-when-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))

(defmacro eval-and-compile (&rest body)
  ;; ... documentation string omitted ...
  (declare (debug (&rest def-form)) (indent 0))
  (list 'quote (eval (cons 'progn body) lexical-binding)))