Why sharp quote lambda expressions?

前端 未结 4 641
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 06:32

It is a technique used frequently in On Lisp, which is on Common Lisp:

> (mapcar #\'(lambda (x) (+ x 10))
         \'(1 2 3))
(11 12 13)
4条回答
  •  无人及你
    2021-02-07 07:02

    The function keyword appears to have had different meanings in different Lisp languages.

    In LISP 1.5, it was used to create a closure, using the funarg device. Reference: http://c2.com/cgi/wiki?DynamicClosure, and the LISP 1.5 Programmers Manual, Appendix B.

    In MacLisp, it was used as a hint to the compiler to say that the lambda expression could be compiled as code. Reference: The Pitmanual, 7. Definitional Forms. It was not used to create closures; the *function special form did something similar. Reference The Pitmanual, 3. The Evaluator.

    In Emacs Lisp, it is a hint to the compiler, and can also create lexical closures. Reference: Emacs Lisp Reference Manual, 12.7 Anonymous Functions.

提交回复
热议问题