In an evaluated context, the relationship between the two forms can be described accurately by saying that LAMBDA is actually a macro that expands the first form into the second one.
(defmacro lambda (&whole whole args &body body)It follows that in an evaluated context, the two forms are thus completely synonymous. Note that the form involving FUNCTION is strictly more primitive, and is what causes the creation of a lexical closure eventually.
(declare (ignore args body))
Howsoever, there are some unevaluated contexts in which you're only allowed to use the former, but not the latter form:
- The CAR of a form must usually be a symbol, naming the function, macro, or special operator that is supposed to be invoked.
As a special exception to that rule (historically for ISLISP compatibility), the CAR of a form can also be (LAMBDA (...) ...).
((lambda (x) (* x x)) 2) ==> 4See CLHS section 22.214.171.124.2.
- The :interactive, :report, and :test arguments of a clause in RESTART-CASE take (LAMBDA (...) ...), but not #'(LAMBDA (...) ...) forms.
- Likewise for the :report option of DEFINE-CONDITION.
- Likewise for the :print-function, and :print-object options of DEFSTRUCT.