From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: tail-call elimination Date: Tue, 11 Dec 2012 08:34:11 -0500 Message-ID: References: <50C6CF11.2000706@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1355232866 13657 80.91.229.3 (11 Dec 2012 13:34:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Dec 2012 13:34:26 +0000 (UTC) Cc: Chris Gray , emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 11 14:34:39 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TiPyp-0004MD-6B for ged-emacs-devel@m.gmane.org; Tue, 11 Dec 2012 14:34:39 +0100 Original-Received: from localhost ([::1]:46927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPyc-0000Ob-Is for ged-emacs-devel@m.gmane.org; Tue, 11 Dec 2012 08:34:26 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPyV-0000Ma-5H for emacs-devel@gnu.org; Tue, 11 Dec 2012 08:34:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiPyP-0000Yi-B9 for emacs-devel@gnu.org; Tue, 11 Dec 2012 08:34:19 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:49558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPyP-0000Yb-7A for emacs-devel@gnu.org; Tue, 11 Dec 2012 08:34:13 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09soXOY/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLDiYSFBgNJIgcBboJkEQDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="209589637" Original-Received: from 108-161-115-152.dsl.teksavvy.com (HELO pastel.home) ([108.161.115.152]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Dec 2012 08:34:12 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id BEBD84E08E; Tue, 11 Dec 2012 08:34:11 -0500 (EST) In-Reply-To: <50C6CF11.2000706@dancol.org> (Daniel Colascione's message of "Mon, 10 Dec 2012 22:13:37 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:155468 Archived-At: >> I have attached a patch that implements tail-call elimination for >> a subset of emacs lisp. This will be helpful in allowing coding >> styles which emphasize tail recursion, such as is usual in languages >> like Scheme. > Your patch eliminates tail calls only in byte compiled code. Until the > interpreter also supports guaranteed tail call elimination or we byte-compile > all forms before evaluating them, elisp developers cannot rely on the > optimization and cannot write idiomatic tail recursive code. I'm not too worried about that. For one, you can argue that bumping into max-lisp-eval-depth for lack of byte-compilation is similar to being too slow for lack of byte-compilation. And in any case we can hope that non-byte-compiled code is on the way to extinction. > As a purely opportunistic optimization, not as a guaranteed language > feature, I doubt tail call elimination is worth the complexity. If it speeds up execution, I think it can be worth the trouble. Stefan