bytecompiler and tail recursion
zevlg at yandex.ru
Fri Oct 8 07:02:51 EDT 2004
Hello XEmacs hackers!
I've got next function:
(defun my-fun (a lst)
(cond ((null lst) a)
(setcar a (+ (car a) (caar lst)))
(setcdr a (+ (cdr a) (cdar lst)))
(my-fun a (cdr lst)))))
Then i did
(my-fun '(0 . 0) (mapcar (lambda (nu)
(cons (random 10) (random 10)))
(make-list 1500 nil)))
And got "Lisp nesting exceeds `max-lisp-eval-depth'" error, having
default `max-lisp-eval-depth' value (1000).
So, here is my question, why bytecompiler did not compliled `my-fun'
as tail recursion function? It is obvious that `my-fun' is tail
recursive and can be easily expanded to loop.
Yes i know that it(`my-fun') can be easily rewritten avoiding
recursion, but it is not the way out for me.
More information about the XEmacs-Beta