Different valid LAMBDAs
(lambda (x) (+ x 10))
LAMBDA
is a macro which expands to (function (lambda ...))
.
#'(lambda (x) (+ x 10))
#'
is a reader macro which expands at read time into (function ...)
.
((lambda ...) ...)
is built-in syntax in Common Lisp. It's defined as a valid form, a valid Lisp expression.
Invalid Lisp form syntax using a LAMBDA
((function (lambda ...)) ...)
is not valid syntax in Lisp.
Valid syntax of compound Lisp forms
There are only the following compound forms valid in Common Lisp:
(<special-operator> ...)
for one of the built-in special operators
(<macro-operator> ...)
(<function-operator> ...)
(<lambda-expression> ...)
The operators are symbols. The latter then has a lambda expression as its first element. Example:
((lambda (x) (1+ x)) 41)
Other syntactic variants are not valid in Common Lisp. Thus ((function (lambda ...)) ...)
and also (#'(lambda ...) ...)
is not valid syntax.
Note
above is slightly confusing, but that's how it is defined in the language standard. The lambda
macro was added later after the initial design of Common Lisp. It allows us to write similar to Scheme:
(mapcar (lambda (x) (+ x 2)) '(1 2 3))
But it is still not the case that the first element of a list gets evaluated, like in Scheme.