I am trying to write a macro that would generate code that looks like:
(defun test ()
(let* ((_ (exp1))
(_ (exp2))
...
(_ (expn)))))
The (expn) calls might be called purely due to their side effects, and it is possible that their return value (stored in _) will never be used. This leads SBCL to emit an style warning: The variable _ is defined but never used.
How can I prevent this warning? I tried declaring the variable as ignorable (through (declare (ignorable _))) in various places in the code but that doesn't work.
This is hard to do and is a somewhat unclear part of the CL standard. In particular in a case like
Which
foodoes the declaration apply to? Or does it apply to all of them?There have been discussions about this and I forget the conclusion. I am fairly sure different implementations differ. In the case where you are generating this
let*form with a macro then the answer is to not do that, but instead generate a set of nestedletforms with appropriate declarations.