Q: When, if ever, is it useful to sharp-quote a
lambda, and when, if ever, must we not sharp-quote a
lambdas in three ways:
(lambda (x) x)
'(lambda (x) x)
#'(lambda (x) x)
Now, the manual node on anonymous functions and the docstring for
lambda note that
lambdas are self-quoting:
A call of the form
(lambda ARGS DOCSTRING INTERACTIVE BODY)is self-quoting; the result of evaluating the lambda expression is the expression itself. The lambda expression may then be treated as a function...
So, it appears that
(lambda (x) x) and
#'(lambda (x) x) are equivalent, but
'(lambda (x) x) is not (most importantly, when byte-compiling).
It looks like one would rarely want to quote a
lambda, but it's unclear to me when, if ever, we should, or should not, sharp-quote:
- Is sharp-quoting a
lambdasimply a stylistic choice, or are there circumstances in which sharp-quoting is actually useful?
- Are there circumstances in which we must not sharp-quote a
lambda, that is, when doing so would alter the meaning of the code?