From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zhu Zihao Newsgroups: gmane.emacs.devel Subject: cl-eval-when -- A workaround for recursive require? Date: Wed, 27 Apr 2022 18:52:07 +0800 Message-ID: <86v8uuwwho.fsf@163.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1734"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 27.2 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 27 14:21:46 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 1njgfy-0000Ht-GS for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Apr 2022 14:21:46 +0200 Original-Received: from localhost ([::1]:48344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njgfx-0005ca-68 for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Apr 2022 08:21:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njgda-00049C-Mz for emacs-devel@gnu.org; Wed, 27 Apr 2022 08:19:19 -0400 Original-Received: from mail-m972.mail.163.com ([123.126.97.2]:21282) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njgdW-0001ab-4g for emacs-devel@gnu.org; Wed, 27 Apr 2022 08:19:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Date:Message-ID:MIME-Version; bh=c4f0/G8/CKv7LSoGCq8ItGYSc4syqZpptqHUJhpbI8Y=; b=YerqLPJEo3M+P 2HO8sgE613g1Fn7tJj9h3ULIVsK73F2cOV7lnT18WZZ84eo/KoJuxFO1CE73cag+ 4AG/4lGSolbMxlgrLAqku6/ZE/XSf9/dEDtpyfga0oPCv3X+CdYXf8Ptls/Hltuz rf/jap3zC6kmDsAxiyzXD9EN9OCmpE= Original-Received: from asus-laptop (unknown [27.38.116.103]) by smtp2 (Coremail) with SMTP id GtxpCgB3L5GnNGliEgt2DQ--.26733S2; Wed, 27 Apr 2022 20:18:47 +0800 (CST) Original-Date: Wed, 27 Apr 2022 20:16:55 +0800 X-CM-TRANSID: GtxpCgB3L5GnNGliEgt2DQ--.26733S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KryxXFyfAw4DWF4UtF4DXFb_yoW8GF45pa y5Kr1YkF4kWr1qvw1vyr4Iv34rurs5ur95GFn5KrWUXrZxJwn2v3yayFWruayUJrs7X39Y q3yDK348Aa9IqaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UoWlPUUUUU= X-Originating-IP: [27.38.116.103] X-CM-SenderInfo: pdoosuxxwbztlvw6il2tof0z/1tbiTwfvr1sGafXawQAAsS Received-SPF: pass client-ip=123.126.97.2; envelope-from=all_but_last@163.com; helo=mail-m972.mail.163.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, INVALID_DATE=1.096, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:288914 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Emacser! I invesitgated into the `cl-eval-when` a time long ago about this `cl-eval-when` hack in the source of magit here. https://github.com/magit/magit/blob/master/lisp/magit.el#L641 A breif summary: magit.el use a `cl-eval-when` block with load time and eval time only evaluation to require its sub-components, while each sub-component use `(require 'magit)` to use procedure in different sub-components. This hack seems to be a hack to avoid recursive require. The result of my investigation I remember is: "Don't use cl-eval-when, it's not robust for many eval strategy combination. eval-when-compile or eval-and-compile are more reasonable alternatives." But today I see a thread on Emacs China forum which refered to this hack in magit.el. First I guess this works because such `require` statements is placed after `provide`, and it's not related to `cl-eval-when`. For testing, I remove the `cl-eval-when` surrounding the require statements in magit.el. But when I compile these files, I see a lot of warning message about function not defined. The bytecomp.el file is a monolith and I don't know how to read and understand it. Curiosity drives me to ask a question here: How does `cl-eval-when` hack works for recurisve require? Is it a ugly hack? =20 =2D-=20 Retrieve my PGP public key: gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F Zihao --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIsEARYIADMWIQRefA5qkqvnKdl/GTlmOX+E92aT+QUCYmk0gxUcYWxsX2J1dF9s YXN0QDE2My5jb20ACgkQZjl/hPdmk/kf/AEAsnQYokNjIIznU5HE5WcobYHbn2I+ fkv5N+Z24vJuSXcBAKtmeGVC189V5YPmHsOo2UDVcpZ2XLclGSywlzZWZUMH =wlr4 -----END PGP SIGNATURE----- --=-=-=--