[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lexical closure bug?



(let ((*fun* nil))
  (do ((a (list 'a 'b 'c 'd 'e) (cdr a)))
      ((endp a))
    (push #'(lambda () (format t "~a~%" a)) *fun*))
  (mapcar #'funcall *fun*))

I think that this should print out something like:

(a b c d e)
(b c d e)
(c d e)
(d e)
(e)

Instead, it prints:
nil
nil
nil
nil
nil

Am I missing something here?
__________________________________________________________________________
Robby Findler                                               robby+@cmu.edu
Carnegie Mellon University    Pittsburgh, PA                (412) 681-4552