Hacker News new | past | comments | ask | show | jobs | submit login

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)

    (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))

    (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 ;-)

A replacement for MULTIPLE-VALUE-BIND, which uses MULTIPLE-VALUE-BIND itself, shows a bit of the value of MULTIPLE-VALUE-BIND.

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

The user needs to learn more than in Java:

1) Learn to deal with a language which has an infinite number of syntactic abstractions.

2) Learn the typical patterns of syntactic abstractions (WITH- , BIND-, DEF- ...).

3) Learn how to write your own abstractions.

Then groups will settle on common (!) Lisp patterns. See for example:


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:


Hopefully this will lead to a modern set of consolidated libraries. Effectively a new Common Lisp standard: CL-20xx

Common Lisp already provides various hash-table traversals with LOOP: http://www.lispworks.com/documentation/HyperSpec/Body/06_aba...

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.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact