emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with eval-when-compile.


From: Helmut Eller
Subject: Re: Trouble with eval-when-compile.
Date: Wed, 31 Aug 2011 16:22:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

* 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]