From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: named-let Date: Mon, 11 Jan 2021 23:28:08 +0000 Message-ID: References: <87im86kub6.fsf@logand.com> <86zh1g62zx.fsf@163.com> <875z4385yd.fsf@logand.com> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37981"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Zhu Zihao , Tomas Hlavaty , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 12 00:29:04 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kz6cS-0009iJ-0e for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Jan 2021 00:29:04 +0100 Original-Received: from localhost ([::1]:33492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz6cQ-0004KT-OG for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Jan 2021 18:29:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz6bj-0003sN-Cd for emacs-devel@gnu.org; Mon, 11 Jan 2021 18:28:19 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:57211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz6bg-0008E8-FK for emacs-devel@gnu.org; Mon, 11 Jan 2021 18:28:18 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTP id 10BNS81M005883; Mon, 11 Jan 2021 23:28:08 GMT In-Reply-To: (Stefan Monnier's message of "Mon, 11 Jan 2021 18:10:17 -0500") Received-SPF: pass client-ip=205.166.94.24; envelope-from=akrl@sdf.org; helo=mx.sdf.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262950 Archived-At: Stefan Monnier writes: >>> With the advent of the native-compiler, "all implementations" is even >>> harder to reach, since it means, interpreter, byte-code, and native code. >> Well as I mentioned the native compiler is already capable of that if >> asked, but in general whichever optimization is done by the >> byte-compiler is picked by the native compiler cause currently the >> compilation input is LAP. So I'm not really sure this is adding much >> complexity from this POV. > > All the patches I've seen so far do it in the bytecode interpreter, > without changing the bytecode itself. Ah okay, as not said, indeed it should use a goto in bytecode. > Note that it also depends on what we mean by TCO. > To me, the "real TCO" is like what Scheme does (so it's not limited to > recursive functions). I don't know how easy it is to implement for > native-comp. Maybe GCC magically does it for us? Nope, AFAIU it does it, but not for us (ATM) :) > [ TCO has also undesirable interactions with debugging/tracing, but > I think that would be a secondary concern which should be > manageable somehow. ] It's also a change in semantic as one must assume that `bar' is not redefining `foo'. (defun foo () (bar) (foo)) Indeed this does not apply for `named-let' where the scope is lexical and so you could do the magic :) >> As a side note I'd be surprised if interpreters in CL implementation are >> supporting TRE, I guess the interpreter is typically used only for debug >> or bootstrap therefore should be not very important. Am I wrong? > > I wouldn't know. But at least for ELisp , it was perceived that > the plain interpreter is important enough that if it doesn't support TCO > then we can't write code which relies on TCO, in which case implementing > TCO in the bytecode interpreter is not very useful. > > [ That's part of the reason why I implemented this limited TCO as > a macro: it works the same for bytecode as for any other mode of > execution so it can really be considered part of the guaranteed > semantics rather than a mere optimization. ] I see. Thanks Andrea