From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#47992: 27; 28; Phase out use of `equal` in `add-hook`, `remove-hook` Date: Mon, 05 Jul 2021 01:15:25 +0200 Message-ID: <87eecdoelu.fsf@web.de> References: <87mttdh57n.fsf@gnus.org> <877di6udfy.fsf@web.de> <87wnq6opfo.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34129"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Daniel Mendler , 47992@debbugs.gnu.org, monnier@iro.umontreal.ca, jakanakaevangeli@chiru.no To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 01:16:17 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1m0BLP-0008NY-Gr for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 01:16:11 +0200 Original-Received: from localhost ([::1]:33054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0BLO-0007r6-J8 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Jul 2021 19:16:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0BLG-0007pn-GQ for bug-gnu-emacs@gnu.org; Sun, 04 Jul 2021 19:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0BLG-0006pG-9E for bug-gnu-emacs@gnu.org; Sun, 04 Jul 2021 19:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0BLG-0000Pb-5K for bug-gnu-emacs@gnu.org; Sun, 04 Jul 2021 19:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Jul 2021 23:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47992 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 47992-submit@debbugs.gnu.org id=B47992.16254405581573 (code B ref 47992); Sun, 04 Jul 2021 23:16:02 +0000 Original-Received: (at 47992) by debbugs.gnu.org; 4 Jul 2021 23:15:58 +0000 Original-Received: from localhost ([127.0.0.1]:43380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0BLC-0000PJ-1d for submit@debbugs.gnu.org; Sun, 04 Jul 2021 19:15:58 -0400 Original-Received: from mout.web.de ([212.227.15.3]:56069) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0BL9-0000P5-5C for 47992@debbugs.gnu.org; Sun, 04 Jul 2021 19:15:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1625440527; bh=3vexodtE5JYmwEA0NI6oa1U+NfcKbxzqonh423LAbSA=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=XUt9jzRQPPd98reJBRXIxaW46VO0ADXfsF8b+Aclk5yF8Bfmdwfq1JNUI/BB/aRok M9Nax1qdR3Xt1Y9/707ZbqRIVCAWL2m8hIpdkdpTBjmJttbLU1wEF/znl2VIYHkA0c qs79QAvWv09ga+j3SGGRG8AS+zUTDIjCaoJ/Lm+w= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.66.201.45]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MJFhX-1lkRtc1IKp-00Kd7S; Mon, 05 Jul 2021 01:15:27 +0200 In-Reply-To: <87wnq6opfo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 04 Jul 2021 03:09:15 +0200") X-Provags-ID: V03:K1:vBZu4daF1CmVUdZfhS/hfqWql/V9/bzvx0wPPk99dfT1x0OBhuA LIlgqBbt+vDl+A7sH8cWXkChN93CC4MySPwXQCADxdMlebss3RMDbg7Y4v/AbFv6Az2DnlI JCnJdzwuNZTy/CBGGsDKJgCcktLs7tTlg+gqDPUO1jX5a8LqRmRxyMe6QwaE7gyutewVTAz MmD2Mhnts1T1n9rbrmPjw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0qE2XWoXYU8=:9tNz798e05kjg/rXPUhG/H NN77LFoxYb71mE8720Os/1S8qhFXH1Lc/ESgfY0itZ12LFhCtIUkXVM+QFuPP/jWrPoeTf0NO fXyk2jiSgRUjy5Qeqj2CC6oxdQt6SstoXjtWF2BObG3ZnigmvIsOe2ZbX73Cxkke/wUXAL1Gq NN9DaV0z8S0ZHJOcnghMPwuVAbUAd6jq8l8cGxdg478MW6nFSjIGRbiWQd/yXG35unyoPj5C+ IFJKj2QG+h14AF3FxuGZdwOb1h7gu1wgu+9d3Xks66VOXFHSctBzGn08JlmLz3IjsUDbDtrLm sVw35FUXMNeOdWpXPKjLFofTFo/vaTJpwxtC0Hx0jwxBs583UGGtrX77y9JFeEAzR1UQzVa1G h3sd0aZEDtzOgE46LnB8OsNjuETBc4Jszy6RUiUb5pvbtr9fa7IrBw7wt/RwGGYjy22qWR6Lb 0IDCNokZJjfIu5YYchl+9Ak/F3NVz+AtQ6LLNqsgoqedlPNV6FHkkh0hiONF4tlBLfVL0buzY FbmdkVkZH/BhVVWckg4SWtoRIVANuvor0LYCSqdGXRfSxvQ8c+i6c4GLFpZwxyVrzCjQ8iPcv SJ9ytYf2ckvenTUcwU7fweAOUPS7qd6kKeFTGpHnF86NGnf3BS4ACRGOpXCAyVamyrvD82Lqh 6RKpTQrc/9KUplQsDlrn1aviaOl7/UFJhoMk5vrgsR3uKt/EHJD3eGCwMXekWFaTfpxNbJpWy UfwmtxzhwqeO1zf0E7jlwGZAXxhqZeQVWiS3Vm6Ci+XcN4kENQSwaDMWpum+yCxLsIst+PtO X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209433 Archived-At: Lars Ingebrigtsen writes: > Some other languages have the ability to add names to anonymous > functions (yes, a contradiction in terms) to aid debugging and the like. > We could also extend our `lambda' with an optional name -- it seems like > that could be generally useful beyond this particular use case -- and > then this new add-hook function could refuse to accept name-less > lambdas... BTW, I think you can have something like that by misusing advice, e.g. (example at the end): #+begin_src emacs-lisp (defalias 'function-name-advice #'identity) ;just a tag (defun named-function (f name) (unless (and (functionp f) (not (symbolp f))) (error "Not an anonymous function")) (when (advice-function-member-p 'function-name-advice f) (error "Already has a name")) (add-function :filter-return (var f) 'function-name-advice `((name . ,name))) f) (defun function-name (f) (and (advice-function-member-p 'function-name-advice f) (cdr (assoc 'name (advice--props f))))) ;; Example: (setq my-test-lambda (lambda (n) (+ 2 n))) (setq my-named-test-lambda (named-function my-test-lambda "Moon Child")) ;; => [bytecode lambda] (funcall my-named-test-lambda 3) ;; => 5 (works) (function-name my-named-test-lambda) ;; => "Moon Child" #+end_src Michael.