Basically, when should I use Emacs Lisp\'s function
procedure? I haven\'t found any examples in which there\'s a difference in behavior if you pass functions as
In addition to the differences when quoting (lambda ...)
forms there has recently (as of Emacs 24.4) been a change to bytecomp.el such that a warning is generated when a #'symbol
form is used, but the function is not known to get defined at the end of the compilation.
Writing all function symbols with the function-quoting #'symbol
syntax rather than the 'symbol
syntax is thus somewhat preferable, since it allows the byte-compiler to check if you have used function names that are actually defined.
Previously (Emacs 24.3 and earlier), while the byte-compiler would warn when you call a function as (no-such-function ...)
and it is not defined or cleanly imported from another file, something like (mapcar #'no-such-function ...)
would have produced only a runtime-error without a compile-time warning.
The change means that both of these scenarios now produce compile-time warnings; however if you use (mapcar 'no-such-function ...)
without using function-quoting then, once again, no compile-time warning can be generated. So the #'
can help find errors (probably typos) early.
Function-quoting also helps with a top-down programming style, since the byte-compiler will then list the functions you have not yet implemented (but will miss functions specified with a normal quote).