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: [PATCH] Improve detection of local function calls in methods Date: Fri, 27 Aug 2021 18:59:11 -0400 Message-ID: References: <878s0mva4u.fsf@gmail.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="11319"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: akater Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 28 01:00:07 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 1mJkpS-0002hY-95 for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Aug 2021 01:00:06 +0200 Original-Received: from localhost ([::1]:60760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJkpQ-00041l-QR for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Aug 2021 19:00:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJkok-0003JD-Oz for emacs-devel@gnu.org; Fri, 27 Aug 2021 18:59:22 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJkof-0001RS-20 for emacs-devel@gnu.org; Fri, 27 Aug 2021 18:59:21 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 78C0E441091; Fri, 27 Aug 2021 18:59:14 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D4DCE44106D; Fri, 27 Aug 2021 18:59:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1630105152; bh=r9XCQG9F545HTZT5Qw0ql7Hrk4ajGCutxA48jTI1HgA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=dIMcd/9t/iNEQaZRK2A/DqJjBzam732KQtI9daoDQHJzZpOPDGUuJbgG0fGk6V6Db 3FdP7AY+lUFyt4Vr6CvPrxEcXJspA3spui/XX3yfY7FZtuf7PpN8tO8+bhAH6h0b9I LhM3WZDepbmHQ6rxzqXdneLHTEqMAzO+dwyS+TCI/2CMFVbshiQqm5PyiY7or9Nttj ZnIZek0rR2YJJENkckLuX6F+/tUN1jb+hHGmJcGwtwHlrhHX4I5DrK1OWNyh9AZcZX cRg1ypcJRf4qG0PUBbFufdSFa2COMgvdmR1ikkvYBJs6+TRVyp6zwcPCpqmguCys4X KuP1EP0eeU2vQ== Original-Received: from alfajor (unknown [104.247.244.135]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A5FA9120223; Fri, 27 Aug 2021 18:59:12 -0400 (EDT) In-Reply-To: <878s0mva4u.fsf@gmail.com> (akater's message of "Fri, 27 Aug 2021 21:41:05 +0000") 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:273197 Archived-At: > Instead of using unreliale and expensive macroexp--fgrep, we record the > relevant calls in the macroexpansion, as suggested in the FIXME entry. Yes, please! > + (defvar cl-generic--uses-cnm nil > + ;; It would be better to declare the variable special > + ;; locally where it's used > + ;; but there is no support for local special declarations in Elisp. [ I'm not completely sure what you mean, but (defvar foo) has an effect limited to the current scope. This said, I don't think it matters much here, because using a globally declared dynvar is perfectly fine IMO (the main reason not to use a globally declared dynvar is either because we really want to keep the global definition unbound or because we really don't want to give the var a namespace prefix). ] > - `(cl-flet ((cl-call-next-method ,cnm) > - (cl-next-method-p ,nmp)) > + `(cl-macrolet ((cl-call-next-method > + (&rest args) > + (prog1 `(funcall ,',cnm ,@args) > + (cl-pushnew > + ',cnm cl-generic--uses-cnm > + :test #'eq))) > + (cl-next-method-p > + () > + (prog1 `(funcall ,',nmp) > + (cl-pushnew > + ',nmp cl-generic--uses-cnm > + :test #'eq)))) Hmm... IIUC this fails to account for the case where #'cl-call-next-method is passed to a function (the most common case (or more precisely, the only case I've seen so far) being when it's passed to `apply`). Stefan