From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Macros considered harmful Date: Tue, 06 Sep 2022 16:13:12 +0000 Message-ID: <87fsh4mqg7.fsf@posteo.net> References: <7e24d0aa-9980-6204-5064-5a92963ae7bd@secure.kjonigsen.net> <83026cfc-8a85-9939-bab4-5b60d4812af9@gmail.com> <87fsh4ikl3.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20036"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel , emacs-devel@gnu.org To: "Basil L. Contovounesios" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 06 18:14:49 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 1oVbDt-0004yr-2M for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Sep 2022 18:14:49 +0200 Original-Received: from localhost ([::1]:48578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVbDs-0000Sd-72 for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Sep 2022 12:14:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVbCT-00080u-54 for emacs-devel@gnu.org; Tue, 06 Sep 2022 12:13:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:43073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVbCQ-0005QQ-J8 for emacs-devel@gnu.org; Tue, 06 Sep 2022 12:13:20 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 63EA6240026 for ; Tue, 6 Sep 2022 18:13:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1662480796; bh=8ANQwXV4YSiwRVVpexw1UcUVJ+GXWuKy26KJzVTEto8=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=PMvs4JJ/87tGr0h72XV4HQJp89D7oJ8h0pT9N4JWJT1GTCjQJ1M+8SH0O2SvvD9uj w3O+JYQK9BiB1Owp4DAe+6hA7OPbIbRInnTzKKY1ObZOwc4PobPvlCNZ0PmFASPz93 pg3VRM5IR1QzEBgGx30MAFmaO0SQjKvbjw7K5vdCSMKso5yWgeEmanU/hbxhvr0yxo ZDXb2CIodVudRmsxHotMkeFUoi6RTD5k8rq+nYYE/XOro41x1iz1XAkP+AjPjEbYwO Vl2uD/EhZlhHcVtJ5Pn0CzCKxSWyRbqktwck91hmoKy9eIZjKNT+0/AvNHVOdjYYCB +Td6iB6MZkAWg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MMVmS4WdHz9rxQ; Tue, 6 Sep 2022 18:13:12 +0200 (CEST) In-Reply-To: <87fsh4ikl3.fsf@tcd.ie> (Basil L. Contovounesios's message of "Tue, 06 Sep 2022 18:33:28 +0300") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, 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:294792 Archived-At: "Basil L. Contovounesios" writes: > Stefan Monnier [2022-09-06 00:44 -0400] wrote: > >> Cl=C3=A9ment Pit-Claudel [2022-09-05 19:53:26] wrote: >>> On 8/20/22 07:14, Stefan Monnier wrote: >>>> FWIW, I think specifying the highlighting rules with something akin to: >>>> (defvar ') >>>> is a mistake. It should go through some kind of macro, such as (maybe= ): >>>> (defvar (tree-sitter-rules )) >>>> which can thus do any preprocessing we may want, such as pre-compiling >>>> queries. It also helps evolve the syntax since we can more easily warn >>>> about obsolete uses, etc... >>>> I've had a "rewrite font-lock.el so the rules go through a macro" in my >>>> todo list for ages. >>> >>> We do things this way in Flycheck, but we've been bitten a few times by= the >>> way this pattern interacts with `with-eval-after-load`, so I would be >>> careful about adopting this pattern in tree-sitter (unless we expect it= to >>> be preloaded). >> >> Very good point. It would introduce a strong compile-time dependency on >> the tree-sitter package, which could be a serious annoyance for random >> `foo-mode` packages which want to keep working in the absence of >> tree-sitter. >> >> Hmm... >> >> [ I guess we'd have to make that macro lightweight and independent from >> tree-sitter itself and put it into a separate package distributed via >> GNU ELPA, so packages can feel free to depend on it. >> Hmm... Another problem. ] >> >>> In fact, I think your suggestion back then was to *not* use a macro? >> >> Indeed, >> >> [ Lua eshews macros altogether for those kinds of reasons, AFAIU. ] >> >> Admittedly, another way around these kinds of problems is to teach the >> compiler how to deal with an unknown macro. I.e. something like >> (declare-macro my-foo ...) so that if the compiler see (my-foo ...) but >> `my-foo` can't be macroexpanded (because the macro is not yet defined), >> it doesn't incorrectly compile it into a function call, but instead >> residualizes it into something like a call to `eval`. Making it >> interact correctly with lexical scoping could be tricky (I guess the >> simplest solution would be to residualize the whole toplevel expression >> in which the macro call was found). > > Another downside of macros not directly addressed by this approach is > that packages using them may have the outrageous desire to both support > older Emacsen and build cleanly, at the same time! Recall, for example, > this unresolved shortdoc thread: > https://lists.gnu.org/r/emacs-devel/2021-09/msg01719.html > > I suppose in the general case this can be alleviated only through > 'compat'-like ELPA dependencies (or by expecting each package to write > its own compatibility shims, of course). As the maintainer of the package "compat", I'd be more than happy to help out with these issues.