From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: tail call reduction
Date: Thu, 10 Feb 2005 23:45:35 +0100 [thread overview]
Message-ID: <877jlg9gq8.fsf@ID-87814.user.uni-berlin.de> (raw)
In-Reply-To: 87psz831tp.fsf-monnier+gnu.emacs.help@gnu.org
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é!
next prev parent reply other threads:[~2005-02-10 22:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-10 9:39 tail call reduction Oliver Scholz
2005-02-10 10:21 ` Oliver Scholz
2005-02-10 14:56 ` Stefan Monnier
2005-02-10 22:45 ` Oliver Scholz [this message]
2005-02-11 4:50 ` Stefan Monnier
2005-03-02 16:20 ` David Combs
2005-03-02 18:06 ` Oliver Scholz
2005-03-04 0:15 ` Miles Bader
[not found] ` <mailman.2542.1109897787.32256.help-gnu-emacs@gnu.org>
2005-03-04 0:56 ` Johan Bockgård
2005-03-04 14:01 ` Miles Bader
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877jlg9gq8.fsf@ID-87814.user.uni-berlin.de \
--to=alkibiades@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).