Last active
August 27, 2022 09:26
-
-
Save y2q-actionman/de1f09b9f474d96e2bb26a433a015f33 to your computer and use it in GitHub Desktop.
(eval-when (:compile-toplevel)) in (eval-when (:compile-toplevel))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#| | |
Some experiments to understand the example of CLHS eval-when explanations. | |
( http://clhs.lisp.se/Body/s_eval_w.htm#eval-when ) | |
;;; #4: This always does nothing. It simply returns NIL. | |
(eval-when (:compile-toplevel) | |
(eval-when (:compile-toplevel) | |
(print 'foo4))) | |
|# | |
(in-package :cl-user) | |
(eval-when (:compile-toplevel) ; Action is 'Evaluate' | |
(print "compile-toplevel") ; Printed only on COMPILE-FILE. | |
(eval-when (:execute) | |
(print "execute in compile-toplevel")) ; Printed only on COMPILE-FILE. | |
;; The forms below are never executed. | |
;; Is it because they are *NOT* top level forms here? | |
(eval-when (:compile-toplevel) | |
(print "compile-toplevel in compile-toplevel")) ; never printed. | |
(eval-when (:compile-toplevel :load-toplevel) | |
(print "compile-toplevel load-toplevel in compile-toplevel"))) ; never printed. | |
(eval-when (:compile-toplevel :load-toplevel) ; Action is 'Process compile-time-too' | |
(terpri) | |
(print "compile-toplevel load-toplevel") ; Printed on COMPILE-FILE and LOAD the fasl. | |
(eval-when (:compile-toplevel :load-toplevel) | |
(print "compile-toplevel load-toplevel in compile-toplevel load-toplevel")) ; Printed on COMPILE-FILE and LOAD the fasl. | |
(eval-when (:compile-toplevel) | |
(print "compile-toplevel in compile-toplevel load-toplevel")) ; Printed only on COMPILE-FILE. | |
(eval-when (:load-toplevel) | |
(print "load-toplevel in compile-toplevel load-toplevel")) ; Printed only on LOAD the fasl. | |
(eval-when (:execute) ; Action is 'Evaluate' | |
(print "execute in compile-toplevel load-toplevel") ; Printed only on COMPILE-FILE. | |
(eval-when (:compile-toplevel :load-toplevel) | |
(print "compile-toplevel load-toplevel in execute in compile-toplevel load-toplevel")) ; never printed | |
)) | |
;;; (load "test.lisp") does not execute any forms above. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment