From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: Trouble with eval-when-compile. Date: Wed, 31 Aug 2011 16:22:50 +0200 Message-ID: References: <20110831135530.GA4169@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1314800603 14120 80.91.229.12 (31 Aug 2011 14:23:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 31 Aug 2011 14:23:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 31 16:23:19 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QylhE-0004KR-Cv for ged-emacs-devel@m.gmane.org; Wed, 31 Aug 2011 16:23:16 +0200 Original-Received: from localhost ([::1]:37704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QylhD-0000Wk-Sq for ged-emacs-devel@m.gmane.org; Wed, 31 Aug 2011 10:23:15 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:40929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QylhB-0000Wf-GP for emacs-devel@gnu.org; Wed, 31 Aug 2011 10:23:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QylhA-0003xU-Da for emacs-devel@gnu.org; Wed, 31 Aug 2011 10:23:13 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:51899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QylhA-0003xL-64 for emacs-devel@gnu.org; Wed, 31 Aug 2011 10:23:12 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Qylh8-0004IR-GR for emacs-devel@gnu.org; Wed, 31 Aug 2011 16:23:10 +0200 Original-Received: from dial-176112.pool.broadband44.net ([212.46.176.112]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Aug 2011 16:23:10 +0200 Original-Received: from eller.helmut by dial-176112.pool.broadband44.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Aug 2011 16:23:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: dial-176112.pool.broadband44.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:lxQFs2VsYgyEVit72+7eOOqJEio= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:143662 Archived-At: * 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