When to use # '(function) before lambda expressions?

I understand, because there are common namespaces for functions and variables in Common Lisp, you can do this:

((lambda (x) (* 2 x)) 3)

and you can also do this:

(funcall #'(lambda (x) (* 2 x)) 3)

When should we use #', not use it? I read in another StackOverflow question that it #'was stored only for historical reasons and should no longer be used. It's true? My question is not a duplicate, I ask when I will use them in my code.

+3
source share
1 answer

lisp -2 lisp -1. lambda , , . #', . lambda function, #' :

LAMBDA

    (lambda lambda-list [[declaration* | documentation]] form*)
 ==  (function (lambda lambda-list [[declaration* | documentation]] form*))
 ==  #'(lambda lambda-list [[declaration* | documentation]] form*)

#'x - (function x), function " ". T

- .

, flet, , . .

(lambda ...) - , , flet, label macrolet, " ", -. (lambda ...) (function (lambda ...)), . .

, , ,

((lambda (x) (* x 2)) 3)

:

(#'(lambda (x) (* x 2)) 3)            ; or
((function (lambda (x) (* x 2))) 3)

((lambda ...) ...) , , lambda . , -, HyperSpec:

3.1.2.1.2.4 -

- , , .

- funcall - . ( - , ​​inline; .)

. 3.1.3 (-).

+6

All Articles