Discussion:
special operator function
Hayley Sha
2019-12-20 23:15:02 UTC
Is there a difference (besides the syntactical one) between
#'(lambda (y) (1+ y)) and
(lambda (y) (1+ y))?
Alan Bawden
2019-12-21 03:39:54 UTC
Post by Hayley Sha
Is there a difference (besides the syntactical one) between
#'(lambda (y) (1+ y)) and
(lambda (y) (1+ y))?
Well, you can write:

((lambda (y) (1+ y)) 17)

But is illegal to write:

(#'(lambda (y) (1+ y)) 17)

I don't know if that difference is what you mean by "the syntactical one".
--
Alan Bawden
Kaz Kylheku
2019-12-21 04:12:04 UTC
Post by Hayley Sha
Is there a difference (besides the syntactical one) between
#'(lambda (y) (1+ y)) and
(lambda (y) (1+ y))?
In ANSI Lisp, the latter expression denotes a form which, if
presented for evaluation, invokes a lambda macro. The expansion of that
macro is the former expression. The evaluation of *that* expression
calculates the function object.

So, under evaluation, they are equivalent via the macro expansion
of one to the other.

Under processing other than evaluation, they may not be equivalent.

Note that #'(lambda (...) ...) is not a Lambda Expression; it's
an (function ...) expression containing an embedded Lambda Expression.

A situation which requires a Lambda Expression, and doesn't evaluate the
expression, will almost certainly not accept #'(lambda ...).

One example of that is the first position of a compound form,
which is not evaluated, but permits a Lambda Expression.
Hayley Sha
2019-12-26 02:22:32 UTC