[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cl-eval-when -- A workaround for recursive require?
From: |
Zhu Zihao |
Subject: |
cl-eval-when -- A workaround for recursive require? |
Date: |
Wed, 27 Apr 2022 18:52:07 +0800 |
Date: |
Wed, 27 Apr 2022 20:16:55 +0800 |
User-agent: |
mu4e 1.6.10; emacs 27.2 |
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?
--
Retrieve my PGP public key:
gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F
Zihao
signature.asc
Description: PGP signature
- cl-eval-when -- A workaround for recursive require?,
Zhu Zihao <=