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: named-let Date: Wed, 13 Jan 2021 09:01:26 -0500 Message-ID: References: <87im86kub6.fsf@logand.com> <86zh1g62zx.fsf@163.com> <875z4385yd.fsf@logand.com> <864kjl8ddr.fsf@163.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23914"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Tomas Hlavaty , emacs-devel@gnu.org To: Zhu Zihao Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 13 15:08:01 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 1kzgoa-00062y-7V for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jan 2021 15:08:00 +0100 Original-Received: from localhost ([::1]:37502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzgoZ-0003Yi-7B for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jan 2021 09:07:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzgiM-0000PP-K4 for emacs-devel@gnu.org; Wed, 13 Jan 2021 09:01:34 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzgiJ-0001Zr-57 for emacs-devel@gnu.org; Wed, 13 Jan 2021 09:01:33 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 74C598090A; Wed, 13 Jan 2021 09:01:29 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 11D2A801F3; Wed, 13 Jan 2021 09:01:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1610546488; bh=77Nxu2odyQ0ehynYf8Ow5NwbYZqV3XjOF2O78e8jEAY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Bl6ZVJvkO0DkCbOL8nnMJEL/6fuMr9wzSkK2VN8+2NKeeMxJTXCnHORP/YVVfJ8xW gXbCjm0X0PIsx4uYlAgRTCXhk1EQ7lRGcei6FTNmldMpq+Nv1s/tmWzGHbJF/hvY73 PCAoUd5ZjZvJx8v5YciPOa4TGDXxXCw8iqI6yEHf7mv0QzQxPoHr7CZ3FwRXtpJSLz oCk1Fgao566KTP4yE8zTlyRBxFM4b7rVKYJtOnc/AHgX4ylAqKF+6PyyOUrjD7hUBl Uk3ehmVrJH1pjrRkT6w4+f49UW1PPe66XjRd6eWqcdtF4XScySonyXIX8wiQTfobzP ifp6wF1DOEgPg== Original-Received: from alfajor (unknown [45.72.224.181]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D28D71202A5; Wed, 13 Jan 2021 09:01:27 -0500 (EST) In-Reply-To: <864kjl8ddr.fsf@163.com> (Zhu Zihao's message of "Wed, 13 Jan 2021 16:11:44 +0800") 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 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:263030 Archived-At: >> And we can also use approaches like "inline, together with a check that >> the function was not advised" for functions which have not been >> officially declared as inlinable (such checks are already used in the >> native-comp code, IIRC, tho just to use "fast call" rather than do >> inlining). > > I'm not sure I understand it. Given code like > > (defun add1 (b) > (+ b 1)) > > (defun test () > (advice-add (intern "add1") :after (lambda (&rest _) > (message "Whoa!"))) > (+ 10 (add1 20))) > > We want to inline (add1 20) so the program becomes (+ 10 (+ 1 20)). But > advice can happened at run time. The inlining would basically lead to the following code: (+ 10 (if (eq (symbol-function 'add1) ) (+ 20 1) (add1 20))) which the compiler might be able to optimize to something equivalent to: (if (eq (symbol-function 'add1) ) 31 (+ 10 (add1 20))) -- Stefan