How do I do closures in Emacs Lisp?

后端 未结 8 1908
感动是毒
感动是毒 2020-12-01 03:12

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:



        
8条回答
  •  心在旅途
    2020-12-01 03:30

    Found another solution with lexical-let

    (defun foo (n) 
        (lexical-let ((n n)) #'(lambda() n)))
    
    (funcall (foo 10)) ;; => 10
    

提交回复
热议问题