association-list a veritable mint for dunning-kruggerands

More maundering on about Lisp

One of the thing that makes CL a pain in the ass sometimes is that there are a lot of strangely named functions specialized for different types of objects. The language has a trillion keywords and a lot of them don’t really help the language learner get comfortable with the language. As an example, iteration:

In the language standard there are a couple of different iteration constructs, do, dolist, docount, and loop. Strangely, there is no doarray. It’s easy enough to write one:


(defmacro do-svect ((counter array) &rest body)
  (let ((ctr (gensym)))
    (dotimes (,ctr (fill-pointer ,array)) 
       (let ((,counter (aref ,array ,ctr)))
     ,@body))))
</code>
</pre>
That's all well and good, but it's a pain to have to write a macro for
each and every sequence type of thing that you have to deal with, and
while I understand why it isn't there, I don't understand why there
isn't some generalforeach` type of function.  It would be easy enough
to write, just a macro that detects the type of the sequence type the
function was called on that writes out the appropriate thing.  There
are a number of situations where this would help a lot, to the
beginner.  Just layer them as macros over the normal syntax and
keywords, which, of course, would all still be there if you needed to
do something more complicated.

Syntax, I think, makes things easier to remember, because (and I’m theorizing here) it calls in some other part of the brain than the part that we use to remember vocabulary, which is what we’re being asked to do with Lisp. I’ve never in my life written a line of Smalltalk, but I can remember that their lambda syntax is something like [ x y | x * y ]. I know very little Erlang, but I know that their binary pattern matching syntax is << x/integer, y/float >> = val. I’ve been reading about lisp for years and staring at it for ten of the last sixteen hours and I’ll be damned if I can remember how to pass multiple values back from a function.

Perhaps Arc will fix all of this, but I think that it would be of no little value to the Lisp community, and to those who want to learn lisp, if people started working on a package that everyone agreed to include and use with their distributions (hah!) that made some things a little easier. It could be something like the modern package that comes with ACL. Hell, everyone could make their own and then we could give them six months, then put them all in a ring and make them fight and then make something more or less agreeable to everyone with the parts that are left over.

Lisp is famed for it’s ability to quickly generate Domain Specific Languages, so perhaps it’s time that we bent that ability towards a different kind of domain, that of learning the language itself. It might also point to the kinds of things that would be interesting to put into the next version of the spec, in the far-off, misty future when that fabled document is actually generated.

<-- Yet another bookshelf update Logic and Implementation -->