0

I've got one file including

(eval-when-compile (require 'cl))

Some other files require this file, and also need to have cl required when they are byte-compiled. This is not happening - this first file does not appear to know it is getting byte compiled, when it is required by other files that are getting byte compiled. Is there a way to craft an eval-when-compile statement in this first file, such that files that require it to also require cl when they are getting byte compiled?

EDIT: Context of the question:

When I download https://github.com/idris-hackers/idris-mode and run make build to byte compile, I get warnings in two separate files, idris-prover.el and idris-repl.el. Both of these files require inferior-idris.el which contains the line (eval-when-compile (require 'cl)). If I add that line to the two files, the warnings disappear. I am wondering if that would be the best solution to fix the warnings. Warnings include:

idris-prover.el:224:44:Warning: `:ok' called as a function
idris-prover.el:239:19:Warning: `:error' called as a function
idris-prover.el:253:67:Warning: `t' called as a function
  • Just put the same thing in each of those files. (This file should anyway not need to know the details of just what each of its required files needs.) – Drew Dec 16 '17 at 2:20
  • Normally when A requires B which requires C and so on, everything defined by C is visible to A. Suppose it's part of B's interface that C is required. Is there a way for A to require B, such that B's eval-when-compile statements are processed just like A's are? – jcarpenter2 Dec 16 '17 at 5:09
  • 1. No, there's no predefined way to do that, as far as I know. (But you can code anything computable using Lisp. ;-) ) 2. This has nothing to do with visibility or interfaces - your "normally" doesn't apply here. – Drew Dec 16 '17 at 5:40
  • I do not understand why my "normally" doesn't apply. Isn't it the case that if C contains (setq hello t), B contains (require C), and A contains (require B), then for succeeding lines in A, hello will be defined as t? – jcarpenter2 Dec 16 '17 at 5:53
  • If A is being byte-compiled, why should eval-when-compile statements not be executed inside the packages that it requires? – jcarpenter2 Dec 16 '17 at 5:54
1

Those warnings indicate actual bugs (from the warnings, I'd guess that the code uses cl.el's case macro) which make the resulting byte-code incorrect.

(eval-wnen-compile (require 'B)) applies only to the given file. Every file which uses cl.el's macros should have such a line (tho I'd argue that it should first be changed to use cl-lib instead, of course).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.