In Common Lisp
and other Lisp-2
s, short for function
. When applied to a symbol
, it returns the function binding
of that symbol
. When applied to a lambda expression
, it returns a lexical closure
formed from that lambda
. Until the lambda macro
was introduced, it was also necessary to use #' before lambda expression
s when passing them as arguments to other functions.
In Emacs Lisp, #' is not necessary. Higher-order functions search both the variable and function bindings of their arguments. Likewise, a lambda expression evaluates to the lambda it expresses (and there are no true lexical closures: they must be simulated with the lexical-let macro). However, #' allows its argument to be byte-compiled, whereas quote or a plain lambda would not.
(apply #'+ '(1 2 3))
(mapcar #'(lambda (x) (* x x)) '(1 2 3 4 5))