defmacro
special-form
(defmacro name (arg*) [doc-string] form*)
Macros are functions that do not evaluate their arguments but use them as given in order to construct and return lisp code which is then compiled and executed.
Typically, the return value of a macro is a backquote (aka quasiquote) expression:
make-html > (defmacro my-trace (expr)
(when $debugging
(var result (gentemp))
`(when $tracing
(var ,result ,expr)
(write-line (string
,(write-to-string expr :escape true)
" => "
(write-to-string ,result :escape true)) :stream $stdlog))))
it: my-trace
The code returned by this macro is always null in no-debug mode, but otherwise...
make-html > (macroexpand '(my-trace (setq x (blabla))))
it: (if $tracing
(do?
(var temp::temp-1 (setq x (blabla)))
(write-line (string "(setq x (blabla))"
" => "
(write-to-string temp::temp-1 :escape true))
:stream
$stdlog)))
code-walk code-walk-list define-compiler-macro define-symbol-macro defmacro gentemp let-symbol-macro letmacro macroexpand macroexpand-1 macroexpand-all