From: Stefan Monnier <monnier@iro.umontreal.ca>
To: jay.p.belanger@gmail.com
Cc: emacs-devel@gnu.org
Subject: Re: Odd behavior of `eval-when-compile'
Date: Sun, 08 Jul 2007 14:51:23 -0400 [thread overview]
Message-ID: <jwv644uzq78.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87odinxyaa.fsf@gmail.com> (Jay Belanger's message of "Sun\, 08 Jul 2007 00\:25\:01 -0500")
> However, if I have a file b.el containing
> (defvar vara 2)
> (defvar varb (eval-when-compile (+ 1 vara)))
> and then byte compile it (in a new Emacs session), I get an error
> Symbol's value as variable is void: vara
Of course: there is no `vara' in the running Emacs: it's only present in the
b.el file which is being compiled but hasn't been loaded yet.
`require' is handled specially by the byte-compiler in that it doesn't just
place a call to `require' in the .elc file but it also loads the file during
byte-compilation. `defvar' isn't special in this way. Maybe we could make
`defconst' special in this way as well, but it hasn't seemed particularly
important until now. You can just do
(eval-and-compile (defvar vara 2))
(defvar varb (eval-when-compile (+ 1 vara)))
-- Stefan
next prev parent reply other threads:[~2007-07-08 18:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-08 5:25 Odd behavior of `eval-when-compile' Jay Belanger
2007-07-08 18:51 ` Stefan Monnier [this message]
2007-07-08 18:54 ` Jay Belanger
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=jwv644uzq78.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=jay.p.belanger@gmail.com \
/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.