Plaster

common-lisp
(cl:in-package #:cl-user) (defmacro foo (s) (format *debug-io* "~&FOO-whatever (~A)~%" s) (eval-when (:compile-toplevel) (format *debug-io* "~&FOO-compile (~A)~%" s)) (eval-when (:load-toplevel) (format *debug-io* "~&FOO-load (~A)~%" s)) (eval-when (:execute) (format *debug-io* "~&FOO-execute (~A)~%" s)) (eval-when (:compile-toplevel :load-toplevel) (format *debug-io* "~&FOO-compile-load NOT execute (~A)~%" s) (eval-when (:execute) (format *debug-io* "~&FOO-compile-load NOT execute then execute! (~A)~%" s))) `(progn (eval-when (:compile-toplevel :load-toplevel :execute) (format *debug-io* "~&GENERATED-compile-load-execute (~A)~%" ,s)) (format *debug-io* "~&GENERATED body. ~A~%" ,s))) (format *debug-io* "~%-----~%~%") (format *debug-io* "~%BAZ0-defun~%") (defun baz0 () (foo "**baz0**")) (format *debug-io* "~%BAZ0-invoke~%") (baz0) ;;; ===> ;; FOO-whatever (**baz0**) ;; FOO-execute (**baz0**) ; wrote xxxxx/x.fasl ; compilation finished in 0:00:00.014 ;;----- ;; BAZ0-defun ;; BAZ0-invoke ;; GENERATED-compile-load-execute (**baz0**) ;; GENERATED body. **baz0** ;;; Note that the "----", "BAZ0-defun", and "BAZO-invoke" lines do not print ;;; at compile time, but do at load. And as beach pointed out, neither does ;;; the (baz0), which is a good thing ***because the function would not exist ;;; at that point.*** ;;; ;;; compile-file creates a file, it does not load the functions. (With some ;;; caveats about compile-time side effects.) The load portion actually loads ;;; what the compile created. ;; Q. -- We're compiling and loading, why don't we see the ;; "FOO-compile" or "FOO-load" lines?