emacs/elisp: What is the hash (pound, number sign, octothorp) symbol used for?

Cheeso picture Cheeso · Apr 23, 2010 · Viewed 13.2k times · Source

What does this do?

(add-hook 'compilation-mode-hook #'my-setup-compile-mode)

...and is it different than

(add-hook 'compilation-mode-hook 'my-setup-compile-mode)

Answer

Trey Jackson picture Trey Jackson · Apr 23, 2010

There is no difference:

(eq 'my-add #'my-add)

yields t

The # can be used in front of a lambda expression indicating to the byte-compiler that the following expression can be byte compiled, see the docs for Anonymous Functions. But there's nothing to compile in the case of a symbol.

In general, it is used in the printed representation along with the left angle bracket (<) to indicate that the object printed is a description (but cannot be read). For example:

#<buffer foo.txt>

It is also used in constructs by the reader to represent circular structures. See the docs for Read Syntax for Circular Objects.

And then you have its use for denoting the base for integers, e.g. #x2c -> 44.

Plus more I'm sure.