help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tail call reduction


From: Oliver Scholz
Subject: Re: tail call reduction
Date: Thu, 10 Feb 2005 23:45:35 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> My main pet Emacs Lisp programming project involves both a lot of
>> parsing and recursively descending of tree-like data structures.
>
> Can you give a short description of one such case where you've bumped
> into problems.  After all, the lack of tail-recursion should only be
> a problem when you implement loops by recursive calls, but unless your tree
> data-structures are very deep, normal recursion should fine.

I don't recall the actual cases where I bumped into problems. IIRC I
got beyond `max-lisp-eval-depth' once or twice with recursive
functions on a depth-first traversal of medium-sized trees. Since the
default of said variable is 300, this should be o.k.. Hm, well, I
guess it was with a loop implemented by recursive calls.

>> But, alas, unless I am much mistaken, proper tail recursion is simply
>> impossible in a dynamically scoped environment.  I could reduce byte
>
> I recommend you check out the lexbind branch which introduces static scoping
> (it still provides dynamic scoping as well, but it should allow tail-call
> elimination in most simple cases).

Ah, of course! Thanks a lot! Wow, it seems, this Emacs manages lexical
variables on the stack ... I am impressed.

    Oliver
-- 
22 Pluviôse an 213 de la Révolution
Liberté, Egalité, Fraternité!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]