How do I do closures in Emacs Lisp?
问题 I'm trying to create a function on the fly that would return one constant value. In JavaScript and other modern imperative languages I would use closures: function id(a) { return function() {return a;}; } but Emacs lisp doesn't support those. I can create mix of identity function and partial function application but it's not supported either. So how do I do that? 回答1: Stupid idea: how about: (defun foo (x) `(lambda () ,x)) (funcall (foo 10)) ;; => 10 回答2: Found another solution with lexical