Higher-order functions in Elisp

后端 未结 3 726
盖世英雄少女心
盖世英雄少女心 2021-02-14 08:56

I created a function that returns a function in Elisp:

(defun singleton-set (elem)
  (defun f (n) (= n elem))
  f)

I try to run this in IELM, a

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 09:23

    How to make functions returning functions possible in Emacs Lisp?

    Using fake closures, and lexical-let.

    What is the reason this mechanism is different from other languages like Python, Scala or Clojure?

    Richard Stallman answered this question in a paper he wrote a while ago.

提交回复
热议问题