Thus, one could make #'(lambda ...) to enable byte compilation of the lambda form.
On the other hand, as mentioned in the manual, this is no longer necessary.
The programmer no longer needs to write (function (lambda ...)) (or the abbreviated # '(lambda ...) , because (lambda ...) expands to (function (lambda ...)) . Other answers explained this very good. First, give the documentation for the function:
From the documentation of the function form:
Like quote , but preferable for objects that are functions. In byte compilation, function compiles its argument. quote cannot do this.
Therefore, the function documentation does not address the difference between
(function (lambda …)) and(lambda …)
but between
(quote (lambda …)) and(function (lambda …)) .
In most modern Lisps (Common Lisp, Scheme, etc.) a form (quote (lambda ...)) or just (lambda ...)) is just a list, and this is not something that can be called up. For example, in SBCL:
* (funcall '(lambda () 42)) ; debugger invoked on a TYPE-ERROR in thread
However, in Emacs Lisp you can call the list:
(funcall '(lambda () 42)) ;=> 42
In the question of whether the function serves any purpose, we must ask "what can we do without it" or "what is its alternative?" We cannot answer that “we will just write (lambda ...) ” because, as others have pointed out, it simply expands to (function (lambda ...)) . If we do not have a function , we can still use quote . We can still write a lambda macro that extends to (quote (lambda ...)) and thus writes (funcall (lambda ...)) , and the code will look the same. The question is, "what's the difference?" The difference is that in the quote version we transfer literal lists, and they cannot be compiled for functions, because we still need to be able to do similar things with them (for example, take a car and cdr ). The function is useful here, regardless of whether we write it ourselves or depend on the macro to use it in the extension. This makes it possible to write function objects instead of lists.