Sharp Quote

last modified: November 26, 2005

#' is a frequently-used ReadMacro in CommonLisp. ("Sharp quote" because # means 'sharp' in MusicalNotation and ' is the QuoteOperator in Lisp.)

#'foo

expands to (is SyntacticSugar for)

(function foo)

Every symbol in CommonLisp can refer to both a function and a value. Since

foo

by itself refers to the value, we write

(function foo)

to refer to the function. The function special form is also used to create a LexicalClosure from a LambdaExpression. (A lambda expression may also be executed directly, but this actually macro-expands to the (function (lambda ... )) form.

In essence, all this means that function is a special form such that (funcall (function <whatever>) ...) evaluates to (<whatever> ...).

See SingleNamespaceLisp, FunctionLambda.


CategoryCommonLisp


Loading...