0

This question already has an answer here:

(elisp) Anonymous Functions says

The following forms are all equivalent:

 (lambda (x) (* x x))
 (function (lambda (x) (* x x)))
 #'(lambda (x) (* x x))

Because (lambda ...) is the most concise, I think it should be preferred. I don't understand why people are still using #'(lambda ...) and (function (lambda ...)) a lot, for example, #'(lambda ...) occurs about 400 times in Emacs's code and 30 times in use-package.el. Here is an example

(defun ibuffer-mark-by-name-regexp (regexp)
  "Mark all buffers whose name matches REGEXP."
  (interactive "sMark by name (regexp): ")
  (ibuffer-mark-on-buffer
   #'(lambda (buf)
       (string-match regexp (buffer-name buf)))))

Is this sole historical legacy? i.e., some (then which?) old versions of Emacs don't think these three forms are equivalent. Or #'(lambda ...) is still relevant nowadays, which can't replaced by (lambda ...).

marked as duplicate by Community Dec 30 '18 at 9:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.