From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: native compilation units Date: Wed, 15 Jun 2022 08:23:45 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14834"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Andrea Corallo , emacs-devel@gnu.org To: Lynn Winebarger Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jun 15 14:35:37 2022 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 1o1SFE-0003Zo-T5 for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jun 2022 14:35:37 +0200 Original-Received: from localhost ([::1]:36966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1SFD-0001lA-SF for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jun 2022 08:35:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1S3w-0001ul-Ar for emacs-devel@gnu.org; Wed, 15 Jun 2022 08:23:56 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:1411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1S3q-0002Yz-QF for emacs-devel@gnu.org; Wed, 15 Jun 2022 08:23:55 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AD675100479; Wed, 15 Jun 2022 08:23:48 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2426B1001D2; Wed, 15 Jun 2022 08:23:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1655295827; bh=Evm82sQ3EaJngpt58zC0CsWxPS1T4YkXALRSO2Oq/Ws=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=T46tAN/mVKJ+16NtrdxI/MmzGJOGNyb+aDWNHleSxXNxM6i4tf8ACALW8gdze5Vkl Fo71SMg0BqjyFsPqV/j1XINId0RvWcicuUrnOslW4qyYGC5HCni3xOnIjI2/AYvQBi 6G2jETpxDfa/sbENyWUNMviYoUkxpSoshWBuPv4qZ/aMGLToglHDf3kA57Q/vU3rzk vlkRV7mETOlu+/4VIlteUIZjylwUVx0Vw1JXITXJEe5jHBAfH5fxEqzJyiiRcgaHdg Q8Pb+ED1+yIC+igns62Zi3YTZuOPt02gGvPIien5+qlG7Bg920FapH05GGnCKzzL89 FDZBFePsZQLTA== Original-Received: from pastel (unknown [45.72.221.51]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DF11D120254; Wed, 15 Jun 2022 08:23:46 -0400 (EDT) In-Reply-To: (Lynn Winebarger's message of "Tue, 14 Jun 2022 23:03:29 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:291207 Archived-At: > The fact that cl-flet (and cl-labels) are defined to provide immutable > bindings is really a surprise to me. Whether they are mutable or not is not directly relevant, tho: the import part is that being lexically scoped, the compiler gets to see all the places where it's used and can thus determine that it's ever mutated. > There is one kind of expression where Andrea isn't quite correct, and that > is with respect to (eval-when-compile ...). You don't need `eval-when-compile`. It's already "not quite correct" for lambda expressions. What he meant is that the function associated with a symbol can be changed in every moment. But if you call a function without going through such a globally-mutable indirection the problem vanishes. > Now the optimizer can treat ct-r1,ct-r2, and ct-r3 as constants for the > purpose of propagation, Same holds for (let* ((a (lambda (f) (lambda (x) (f (+ x 5))))) (b (lambda (y) (* y 3))) (f (funcall a b))) (lambda (z) (pow z (funcall f 6)))) >> It's also "modulo enough work on the compiler (and potentially some >> primitive functions) to make the code fast". > Absolutely, it just doesn't look to me like a very big lift compared to, > say, what Andrea did. It very depends on the specifics, but it's definitely not obviously true. ELisp like Python has grown around a "slow language" so its code is structured in such a way that most of the time the majority of the code that's executed is actually not ELisp but C, over which the native compiler has no impact. > Does this mean the native compiled code can only produce closures in > byte-code form? Not directly, no. But currently that's the case, yes. > below with shared structure (the '(5)], but I don't see anything in > the printed text to indicate it if read back in. You need to print with `print-circle` bound to t, like the compiler does when writing to a `.elc` file. > I'm sure you're correct in terms of the current code base. But isn't > the history of these kinds of improvements in compilers for functional > languages that coding styles that had been avoided in the past can be > adopted and produce faster code than the original? Right, but it's usually a slow co-evolution. > In this case, it would be enabling the pervasive use of recursion and > less reliance on side-effects. Not everyone would agree that "pervasive use of recursion" is an improvement. > Improvements in the gc wouldn't hurt, either. Actually, nowadays lots of benchmarks are already bumping into the GC as the main bottleneck. > ** The 'lexical-binding' local variable is always enabled. Indeed, that's misleading. Not sure how none of us noticed it before. Stefan