unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cl-eval-when -- A workaround for recursive require?
@ 2022-04-27 10:52 Zhu Zihao
  2022-04-29 17:36 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Zhu Zihao @ 2022-04-27 10:52 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-02  0:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 10:52 cl-eval-when -- A workaround for recursive require? Zhu Zihao
2022-04-29 17:36 ` Stefan Monnier
2022-04-30 17:09   ` Zhu Zihao
2022-05-02  0:30     ` Richard Stallman
2022-05-01 18:36   ` Jonas Bernoulli

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).