From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: tail call reduction Date: Thu, 10 Feb 2005 23:45:35 +0100 Message-ID: <877jlg9gq8.fsf@ID-87814.user.uni-berlin.de> References: <87k6pgwy7u.fsf@ID-87814.user.uni-berlin.de> <87psz831tp.fsf-monnier+gnu.emacs.help@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1108076004 19157 80.91.229.2 (10 Feb 2005 22:53:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Feb 2005 22:53:24 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 10 23:53:24 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1CzNAF-0000fU-Pw for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Feb 2005 23:52:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CzNP4-00053v-C8 for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Feb 2005 18:07:18 -0500 Original-Newsgroups: gnu.emacs.help X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6; Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:BSBq2V6dpV/54if/a+vEfrRnhHw= Original-NNTP-Posting-Host: 84.58.34.253 Original-X-Trace: 10 Feb 2005 23:46:18 +0100, 84.58.34.253 Original-Lines: 30 Original-X-Complaints-To: abuse@arcor-ip.de Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newshosting.com!nx01.iad01.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!newsfeed.arcor-ip.de!news.arcor-ip.de!84.58.34.253 Original-Xref: shelby.stanford.edu gnu.emacs.help:128485 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org X-MailScanner-To: geh-help-gnu-emacs@m.gmane.org Xref: main.gmane.org gmane.emacs.help:24017 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:24017 Stefan Monnier 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é!