> In article , > Ken Tilton wrote: > > Stefan Arentz wrote: > I finally got my copy of Practical Common Lisp so I'm going over the first > few chapters again. Great stuff but questions keep popping up. I hope this > group doesn't mind :-) > > Here is a simple one. In chapter3 there is the following code > > (remove-if-not #'evenp (list 1 2 3 4 5)) > > (remove-if-not #'(lambda (x) (= 0 (mod x 2))) (list 1 2 3 4 5)) > > I understand why in the first case #' is used as it is a shortcut for > (function 'evenp) right? > > (remove-if-not 'evenp ...) also works. There is a subtle difference, I just forget. Something about if the function exists when the code gets compiled? The subtle difference comes up when the function is in a variable and the function is redefined after assigning to the variable. (defvar *test-function-1*) (defvar *test-function-2*) (defun test-fun () 'old) (setq *test-function-1* 'test-fun) (setq *test-function-2* #'test-fun) (defun test-fun () 'new) (funcall *test-function-1*) => NEW (funcall *test-function-2*) => OLD *TEST-FUNCTION-1* contains the function's name, so it always gets the current definition of that name. *TEST-FUNCTION-2* contains the function object itself; when function is redefined, a new function is created and associated with the name, but this has no effect on references to the old function. - Barry Margolin, barmar@xxxxxxxxxxxx Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***