* Trouble with eval-when-compile.
@ 2011-08-31 13:55 Alan Mackenzie
2011-08-31 14:22 ` Helmut Eller
0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2011-08-31 13:55 UTC (permalink / raw)
To: emacs-devel
Hi, everybody.
Any chance of a tip?
I have two files like this (grossly simplified, of course):
when-compile-sub.el:
(defconst str "Foo")
(provide 'when-compile-sub)
when-compile.el:
(eval-when-compile
(require 'when-compile-sub))
(defconst strng `,str)
(message "strng is %s" strng)
I think it's clear what I want to do - that is, to (require
when-compile-sub.elc) only at compile time, and use the value of a
constant at runtime in the main file.
Both files compile OK. But when I try to load when-compile.elc, with
emacs -Q -batch -l when-compile.elc
, I get the error message:
Symbol's value as variable is void: str
What is going on here? str is merely a compile time constant. Why is
anything about str still hanging around at runtime?
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Trouble with eval-when-compile.
2011-08-31 13:55 Trouble with eval-when-compile Alan Mackenzie
@ 2011-08-31 14:22 ` Helmut Eller
0 siblings, 0 replies; 2+ messages in thread
From: Helmut Eller @ 2011-08-31 14:22 UTC (permalink / raw)
To: emacs-devel
* Alan Mackenzie [2011-08-31 13:55] writes:
> Hi, everybody.
>
> Any chance of a tip?
>
> I have two files like this (grossly simplified, of course):
>
> when-compile-sub.el:
> (defconst str "Foo")
> (provide 'when-compile-sub)
>
> when-compile.el:
> (eval-when-compile
> (require 'when-compile-sub))
>
> (defconst strng `,str)
> (message "strng is %s" strng)
>
> I think it's clear what I want to do - that is, to (require
> when-compile-sub.elc) only at compile time, and use the value of a
> constant at runtime in the main file.
(defconst strng (eval-when-compile str))
would work better.
>
> Both files compile OK. But when I try to load when-compile.elc, with
>
> emacs -Q -batch -l when-compile.elc
>
> , I get the error message:
>
> Symbol's value as variable is void: str
>
> What is going on here?
`,str is rewritten to str
> str is merely a compile time constant. Why is
> anything about str still hanging around at runtime?
The value of a named constant is stored in the value slot of its symbol.
I guess that's less problematic with regard to eq-ness than dumping the
value to the .elc file and reconstructing it on load time.
Helmut
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-31 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-31 13:55 Trouble with eval-when-compile Alan Mackenzie
2011-08-31 14:22 ` Helmut Eller
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.