Iterators in Lisp


(dolist (x l) (print x))

(mapc #'(lambda (x) (print x)) l)

(mapc #'print l)
This is a bit of a naughty place to start, but indulge me. I gave a version of this talk at the conference last April. Shortly after that, I came by accident across a 1993 paper by Henry Baker published in ACM OOPS Messenger entitled Iterators: Signs of Weakness in Object-Orientated Languages. Baker is a pretty distinguished computer scientist, who's made strong contributions to garbage collection, functional programming, and linear logic. He was at MIT, and one of the founders of Symbolics. He rides a unicycle. So that probably gives you some idea of the kind of thing he's interested in.

These little examples come from that paper. I've worked with Scheme in the past, but I won't confess to be fresh on anything Lispy. They print the elements of list l. Theses forms are all equivalent - dolist can implemented in terms of mapc - the macro definition at the bottom there is an approximation of CL 'dolist'

Iterators: Signs of Weakness in Object-Orientated Languages