Get in the habit of using sharp quote10 Nov 2014, by Artur Malabarba.
The sharp quote (or function quote, or simply
#') is an abbreviation
function form. It is essentially a version of
which enables byte-compilation, but its actual usefulness has changed
throughout the years.
A little over two decades ago, it was used to quote
'(lambda (x) (* x x)) was just a raw list to the
#'(lambda (x) (* x x)) was an actual function
that could be compiled. Now-a-days—or rather, now-a-decades—the
lambda form sharp-quotes itself, meaning a plain
(lambda (x) (* x
x)) is identical to the
#' version. In fact, you should never
quote your lambdas with either quotes.
On the other hand, just as you'd expect the sharp quote to become
redundant for the elisp programmer, a new use arises for it. The
compiler throws a warning whenever it notices you've used an undefined
(not-defined "oops"), but it can't do the same for
(mapcar 'not-defined some-list) because it doesn't
know that symbol is the name of a function. The sharp quote is a way
of conveying that information to the compiler, so if it runs into
(mapcar #'not-defined some-list), it can throw a warning
So it is always good practice to sharp quote every symbol that is the
name of a function, whether it's going into a
funcall, or anything else. Adhering to this actually unearthed a
small bug in one of my packages.
And of course, we can make things more convenient.