0

I'm not an expert in Emacs Lisp, but I do believe that I know the basics, but in this very basic (minimal reproducible example) instance of the very widespread pattern of using a function as an argument (a pattern I believe to have successfully used in elisp often already) it fails:

(defun test (f)
  (f 5))

(test (lambda (x) (message (format "%d" (+ x 20)))))

Instead of printing "25" it gives the error "Symbol's function definition is void: f".

I tried to search for it, but couldn't find the problem.

Thanks for an answer!

zvavybir
  • 1,034
  • 6
  • 15
  • 1
    Emacs Lisp is a Lisp-2 and so putting a function in a variable does not create a function by that name in the function name-space; function values stored in variables must be `funcall`'d (or similar). – phils May 23 '23 at 01:12

0 Answers0