opening it up with Common Lisp

Favorite weblogs

Lisp Related

Bill Clementson

Finding Lisp


Planet Lisp



Talking Points Memo

This Modern World

Working for Change

Other home


Recent Readings

Book review: Darwinia
Reviewed: Friday, August 11, 2006

Summer reading: Spin
Reviewed: Saturday, August 5, 2006

Reviewed: Tuesday, July 18, 2006

the Omnivoire's Delimma
Reviewed: Wednesday, July 12, 2006

the Golem's Eye
Reviewed: Wednesday, May 31, 2006


Something to worry about (but not much)
Tuesday, January 10, 2006

(Update, don't read this. I make a minor fool of myself and now I feel embarrassed).

What does:

(let* ((*a* 1)
       (f (lambda (&rest args)
              (declare (ignore args)) *a*)))
  (print (funcall f))
  (let ((*a* 3))
    (print (funcall f)))

print? If you guessed "1, then 3" then you were correct. How about:

(let* ((*a* 1)
       (f (constantly *a*)))
  (print (funcall f))
  (let ((*a* 3))
    (print (funcall f)))

If you guessed "1, then 3" then you disagree with every Lisp I've asked. I've tried this with and without optimizations and assume that the compilers are being clever with the constantly (even though CLTL2 says that constantly can be defined as:

(defun constantly (object)
   #'(lambda (&rest arguments) object))

I don't know the standard backwards and forwards well enough to say that one answer is better than another. Does anyone else know chapter and verse?


Home | About | Quotes | Recent | Archives

Copyright -- Gary Warren King, 2004 - 2006