Common Lisp is a programmable programming language.
You need to hack around it. Don't like it? Improve it. Sketch:
(defun make-vars (vars &aux syms)
"creates uninterned symbols for vars named NIL.
Returns a list with those replaced and a list of the new syms."
(values (loop for var in vars
if (eq var NIL)
collect (let ((sym (gensym "ignore"))) (push sym syms) sym)
else collect var)
syms))
(defmacro multiple-value-bind-some (vars form &body body)
"Similar to MULTIPLE-VALUE-BIND, but variables named NIL will be ignored."
(multiple-value-bind (vars syms) (make-vars vars)
`(multiple-value-bind ,vars ,form
(declare (ignore ,@syms))
,@body)))
Example
(defun foo (x)
"returns five values"
(values x (* x 2) (* x 3) (* x 4) (* x 5)))
(defun test ()
(multiple-value-bind-some (a nil nil nil b)
(foo 10)
(list a b)))
I have a hunch that you defined make-vars as a separate function just to be able to nest two multiple-value-bind, one in the macro and one in the expanded form ;-)
Yeah, that's a great example of the power of Lisp!
Of course it now also leads to one of Lisp's other problems; namely that after a while everyone ends up programming in their own private language of accumulated hacks :D
There are lots of libraries which provide language extensions, which are used by many people.
The extremes in Lisp are then:
* no syntactic abstractions -> the power of Lisp wasted
* using those syntactic abstractions which are approved by user groups, due to inclusion into libraries
Above choices are relatively conservative.
As another extreme, it is fully possible to change the language - but then Common Lisp provides more than macros to do so. See for example reader macros, CLOS MOP, customs evaluators/compilers, code walkers, ...
Yeah, I use Alexandria by default in every project now. I remember when I first started coding in Lisp, I wrote a ton of obvious functions/macros like the missing hash table traversals that are in Alexandria but are rather bizarrely missing from the Common Lisp spec. Then I found Alexandria and realised I'd written a good fraction of those functions myself! This was pre-quicklisp, so library discoverability wasn't great.
Now I'm trying to make a concerted effort to follow the recommendations here:
That's a good point. I always tend to forget about loop because I don't use it all that much, prefer using the Iterate library. Loop is a whole extra language all on its own.
You need to hack around it. Don't like it? Improve it. Sketch:
Example