I\'m familiar with Emacs Lisp, but not Common (or any other) Lisp. Some Lisp programmers suggest (e.g. A basic function for emacs) that it\'s good to use #\'
in fr
The quote character in #'foo
has nothing to do with the one in 'foo
.
#'foo
is replaced at read time by (function foo)
. When that is compiled and executed, it looks up the functional definition named by foo
(by defun
, flet
, labels
or similar).
'foo
is replaced at read time by (quote foo)
. When that is compiled and executed, it is simply replaced by the symbol foo
.
Funcall
and apply
(and thus generally higher order functions) take function designators as arguments. A function designator can be a function or a symbol naming a function, so both #'foo
and 'foo
are function designators.
Therefore, the forms 'foo
and #'foo
seem interchangable at first glance. However, the lookup of the real function is done at different times—#'foo
is looked up where it is invoked, while the function named by 'foo
would only be looked up when it is finally applied.
If you use a function designator many times over, it is much more efficient to do the lookup just once, or even just at compile time. That can be a really big timesaver, and translates to a smoother user experience in an editor.