[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
do-nothing macro generates nil nevertheless
- To: email@example.com
- Subject: do-nothing macro generates nil nevertheless
- From: firstname.lastname@example.org (Dave Yost)
- Date: 26 Feb 1995 20:19:19 GMT
- Organization: Dave Yost's house
- Sender: email@example.com
I've been implementing some debug macros that only
generate code depending on what's in *features*. If
the appropriate features are not enabled, I want my
macros to have no effect. As if they weren't there.
This seems not to be possible.
Consider this macro:
(defmacro mac1 () nil)
Now consider this form:
which returns nil. (in MCL and CMU-CL)
This seems to me to be a misfeature.
A macro's job is to return a list to be compiled.
If it returns nil, I would have thought that would mean
that nothing should be compiled. That would be useful.
If you need a macro to compile in the constant nil, you
can have it return 'nil.
(defmacro mac2 () 'nil)
returns nil in MCL and CMU-CL.
While we're on the subject of debug printouts,
it would be nice if there were a way one could insert
a form after the last expression of a progn and have
it be transparent with respect to what the progn
returns. Over-simplified example:
You'd like the return value to be 3, as if you'd done this
which is even more invasive. For debug forms like this
it would be nicer if they were defined to be usable
anywhere without worry as to their effect on return values.
This would require some sort of primitive like
(return-value-transparent &body body)
which would leave the current return values undisturbed.
This primitive could stand on its own, or it could be
implemented using an even more useful primitive:
(with-captured-return-values (var) &body body)
which could be useful in a macro that would expand thus:
(debug-print "You're about to return ~S" var)
Has this been done before?
Isn't lisp great?