lispcommon-lisppractical-common-lisp

Is there a difference between `#'(lambda... ` and `(lambda...`?


In Practical Common Lisp there is a example of REMOVE-IF-NOT with a lambda:

CL-USER> (remove-if-not #'(lambda (x) (evenp x)) '(1 2 3 4 5))
(2 4)

Is this any different from:

CL-USER> (remove-if-not (lambda (x) (evenp x)) '(1 2 3 4 5))
(2 4)

Is a (lambda..) value coincident to the quoted-function form #'(..)? On the REPL it seems so, but as I'm new to Lisp I may overlook something (and I surely got the verbiage wrong, so please correct me on that too).


Solution

  • These two things are, as you suspect, the same:

    This means that #'(lambda (...) ...), (lambda (...) ...) and (function (lambda (...) ...)) all are the same thing in CL: they all denote the function specified by (lambda (...) ...) in the current lexical environment.

    There are two reasons why people might still use the #'(lambda (...) ...) version: