all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Trouble with eval-when-compile.
Date: Wed, 31 Aug 2011 16:22:50 +0200	[thread overview]
Message-ID: <m21uw17j9h.fsf@gmail.com> (raw)
In-Reply-To: 20110831135530.GA4169@acm.acm

* 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	other threads:[~2011-08-31 14:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 13:55 Trouble with eval-when-compile Alan Mackenzie
2011-08-31 14:22 ` Helmut Eller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21uw17j9h.fsf@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.