From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: akater Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Improve detection of local function calls in methods Date: Fri, 10 Sep 2021 06:25:57 +0000 Message-ID: <87ee9xq74a.fsf@gmail.com> References: <878s0mva4u.fsf@gmail.com> <87zgt0sdbg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="983"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 10 08:38:23 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 1mOaB4-000Adg-KW for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 08:38:22 +0200 Original-Received: from localhost ([::1]:43720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOaB3-0002jJ-G3 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 02:38:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOaAE-0001uN-7N for emacs-devel@gnu.org; Fri, 10 Sep 2021 02:37:30 -0400 Original-Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:43779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOaAC-0003zh-Ns for emacs-devel@gnu.org; Fri, 10 Sep 2021 02:37:29 -0400 Original-Received: by mail-wr1-x429.google.com with SMTP id b6so1042222wrh.10 for ; Thu, 09 Sep 2021 23:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=qeJonvvvYqaRqP1Q6QSSC+nnzHb6v0icR4SQll2xJwU=; b=KVp2wRKpjYWPTiySbhUDxkP/n3TYbX6VxfqagRzMMSfXY/HIDje3nb2o2s1d9Y07FZ pI3Bu04jC3u2OCe7MqFoC0e82MGkazqGUB+jsDTPddj5z7jnRoJP8kuXTY0XgGds+Vgn h51JDw6U3fDsQUvsD7p/pABNusTzKSL8SVYdc1/SBXh0OH1A1qEvEEGvJcFq83YFRNFi TRtHIQz0yob58ekesU8E3NcJN7M2a1oWpoVmSv3jwr134IKIzipSa61D0ep+hSVlb+et 4OQIyYLkZWr5xGZNnU93xvAA1PjTUjFS91TsNZooXwCBrwYmB5yriXZW0mcfD/UutWva SE9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=qeJonvvvYqaRqP1Q6QSSC+nnzHb6v0icR4SQll2xJwU=; b=Kf3XyksK3hGietZBzseD44aYH3mQLFa6D/OFLEMrk+MKjOn2jLPS4b/tnzdCZtdUvS jKZqhr8jC/oF85Bf1hUIJybxzru7UFkllv8KrpoGg4KjHcbEedLqoLv8t5hmnKGiwhQR VboQXca2IBznJaBtoClrdXY0jTTUzhKoNAeJF7iqJ4eqlHlpJ+LrREdx9b19OxN9unfP NyaiFyuAqhvSSnBK4uvnP8XFKjxpburcK5QqC6/3zHJY2UAXgtRCbcnNsWrD75IeMcZb PVxEH8ewS9eJ22fYocG+1IKhBIbBmglKY2lxjgvYRRZJ6oC8PfIIAJ36UFQ8i6lijmUV 6UvA== X-Gm-Message-State: AOAM530YssU08j2UbL/ePMC5X8lLQnMRJnXK+yFkvGc8lnS3RHcqscnB nJaP+FRKM6FSn4DqcnbacTa0++cJJgE= X-Google-Smtp-Source: ABdhPJyTNimwam1Bch+o42lVG1tU6elEVhplLrMcny7+e25C0oE1G88T0oSuYCzrvrCF+DMmrLT1ew== X-Received: by 2002:a5d:6a8b:: with SMTP id s11mr7831886wru.127.1631255846135; Thu, 09 Sep 2021 23:37:26 -0700 (PDT) Original-Received: from localhost (tor-exit-10.zbau.f3netze.de. [185.220.100.249]) by smtp.googlemail.com with ESMTPSA id s15sm3758258wrb.22.2021.09.09.23.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 23:37:25 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=nuclearspace@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:274496 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: > I think "the right way" would be for the `cl-flet` implementation to use > a `cl--expand-flet` function returning which functions are used > and which aren't. > > Then we could use it here without such duplication, *and* we could use > it in `cl-flet` to emit warnings about unused functions. > > WDYT? I agree. I think the root of the problem is, ~cl-flet~ is generally not implemented well. Feels like it was implemented in a rush. =2D (func exp) is non-standard and ad-hoc. Do you happen to remember, maybe it was invented solely for ~cl--generic-lambda~? =2D (func exp) definition form is described incorrectly in the docstring: it should be (FUNCTION-NAME SYMBOL) and so on; this also affects cl-macrolet docstring which claims it's =E2=80=9Clike cl-flet=E2=80=9D bu= t in fact it's not as it doesn't support this definition form =2D ~cl-flet~ with invalid function names should error but it doesn't I implemented ~cl--expand-flet~ but I felt simply returning a list of used symbols would be just another ad-hoc addition so I decided to instead add an interface to execute arbitrary code during macroexpansion. It took longer than I expected but I'm satisfied with the result. I'll open a standalone bug (my implementation happens to fix some outstanding issues); when changes are (hopefully) merged, we'll continue on with this one. Quick reference: if all goes well, the definition of ~cl--generic-lambda~ is to become #+begin_example emacs-lisp .. (let* ((parsed-body (macroexp-parse-body body)) uses-cnm (cnm (make-symbol "cl--cnm")) (nmp (make-symbol "cl--nmp")) (nbody (cl--expand-flet macroenv (cdr parsed-body) (cl-call-next-method (push cnm uses-cnm) cnm) (cl-next-method-p (push nmp uses-cnm) nmp))) ;; FIXME: Optimize the case where call-next-method is ;; only called with explicit arguments. ) ..) #+end_example This involves a =E2=80=9Cmacro=E2=80=9D version of expand-flet; we'll see w= hether it's worth keeping alongside the corresponding function. If you can, please confirm my suspicion that (FUNC EXP) definitions were indeed invented solely for ~cl--generic-lambda~. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJLBAEBCgA1FiEEgu5SJRdnQOF34djNsr6xYbHsf0QFAmE6+nUXHG51Y2xlYXJz cGFjZUBnbWFpbC5jb20ACgkQsr6xYbHsf0SdzRAAvu1urCNdYKAHRjip6K5BrSjG jxn74YRAxbojOVnrrz5LGAD8Oh7I2PAaMsaB6DCklJyDT1lby3UBhKvE2NG9zjLi HL2TCvEWVPvd64T48AJMMH+jz/3mRgl5Rsphl06JY8gP55ybuZrm68RqpDIAji1n L0FkrKsOqpyXNxAYQEn8b5lVx6JIEJK2jtxGw+wJEe2xGZCZ5dD2K6XUon7nwOzX DcW8Uid9tjru+69xSP2X6vBG1+SuEAMW5ly01nYSEMgG4BVhMafbAGSmciKB5w9Y kQ2WzOG1eyz7vyTiTJHkMuQvdZovNp/ZCtC2bfkpw1vjy1zjjInwPDkrEv2Vvnf5 KMWOk5Bci/+Jvg9n6Ce88UShTzL/sSfYDaSUVaT+4wy9GIDnl0nb4JsO5yizgEPo 1y3YpaiVFM65IJXCO7m+A6xqjrFmFBqxuOMPAy3h/PA/OJJ+99q/cqpOut3oMv3P 5xPxkfaAeqrppW6u1l67zx4C/ZAudeE2dE2x4yadHZIvbm3v/y3mRWpY4GuCHW4q 4AdPbOePScKPISeFZdtR4CA/KZFj04169hoSE/vJ1I9+JpIGgG3sd0X7J5v2CqM9 JXHjo6KrGXai1Iyao/O83BPdzXvQClEQq7UkXRsA2Fi3nf3iI1wc4v//oaiFiHi5 BvWOpD3PT5D/JET1Rc0= =RpK6 -----END PGP SIGNATURE----- --=-=-=--