I want to define a macro which can comment a s-expression, for example:
I hope that
(list 1 2 (comment-macro (something))) -> (1 2)
But if I define the macro like this
(defmacro comment-macro (x))
the result of the above form is actually
(1 2 nil)
You cannot accomplish what you want with a regular macro because its primary value (or nil
if no values are returned) will always be used.
However, there are two common options:
comment: #| ... |#
- for general text
feature expressions: #+(or) ...
or #-(and) ...
- for (temporarily?) disabling code
You can also define your own read macros using set-macro-character
and set-dispatch-macro-character
.
In Common Lisp, there is no way to define a macro which expands to nothing. The primary value returned from the macro (i.e. the macro function) is always inserted in place of the macro call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With