Exceed evaluation depth when forward function in Emacs Lisp -
here simplified code snipped have not managed work. not understand wrong.
(defun enumerate-indicies (func) (let ((index 0)) (while (< index 5) (funcall func index) (setq index (1+ index))))) (defun enumerate-multiplied-indicies (func) (enumerate-indicies #'(lambda (index) (funcall func (* 10 index)))))
the following testing code returns 10
expected:
(defun test/enumerate-indicies () (let ((sum 0)) (enumerate-indicies #'(lambda (index) (setq sum (+ sum index)))) sum)) (test/enumerate-indicies)
but below causes error lisp nesting exceeds max-lisp-eval-depth
in emacs:
(defun test/enumerate-multiplied-indicies () (let ((sum 0)) (enumerate-multiplied-indicies #'(lambda (index) (setq sum (+ sum index)))) sum)) (test/enumerate-multiplied-indicies)
could please give clue? not supposed recursive call here seems is. thanks.
how using lexical-let
penetrate lambda
? correct answer 100?
(defun enumerate-indicies (func) (let ((index 0)) (while (< index 5) (funcall func index) (setq index (1+ index))))) (defun enumerate-multiplied-indicies (func) (lexical-let ((func func)) (enumerate-indicies #'(lambda (index) (funcall func (* 10 index)))))) (defun test/enumerate-multiplied-indicies () (lexical-let ((sum 0)) (enumerate-multiplied-indicies #'(lambda (index) (setq sum (+ sum index)))) sum)) (test/enumerate-multiplied-indicies)
Comments
Post a Comment