From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Achim Gratz Newsgroups: gmane.emacs.devel Subject: eval-when-compile Date: Fri, 27 Jul 2012 07:01:51 +0200 Organization: Linux Private Site Message-ID: <871ujx94qo.fsf@Rainer.invalid> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1343365334 10859 80.91.229.3 (27 Jul 2012 05:02:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Jul 2012 05:02:14 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 27 07:02:14 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sucgn-00082j-Rv for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2012 07:02:13 +0200 Original-Received: from localhost ([::1]:46311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sucgn-0005lX-7T for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2012 01:02:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sucgh-0005lP-Aj for emacs-devel@gnu.org; Fri, 27 Jul 2012 01:02:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sucgf-0002Rv-6R for emacs-devel@gnu.org; Fri, 27 Jul 2012 01:02:07 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:36676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sucge-0002Rb-WB for emacs-devel@gnu.org; Fri, 27 Jul 2012 01:02:05 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Sucgd-0007vr-Gm for emacs-devel@gnu.org; Fri, 27 Jul 2012 07:02:03 +0200 Original-Received: from pd9eb3436.dip.t-dialin.net ([217.235.52.54]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jul 2012 07:02:03 +0200 Original-Received: from Stromeko by pd9eb3436.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jul 2012 07:02:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: pd9eb3436.dip.t-dialin.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:3cDsp6gQca3U6S2OoC8BFPKvLNQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:151899 Archived-At: [I hope this is the correct list for asking this question.] I've been trying to use eval-when-compile to switch between alternate versions of code based on a compile-time decision. However it seems that either I don't understand the documentation or something doesn't quite work. Compiling this source file: --8<---------------cut here---------------start------------->8--- (eval-when-compile (if t (defvar unquoted-t "true") (defvar unquoted-nil "false"))) (eval-when-compile (if nil '(defvar quoted-t "true") '(defvar quoted-nil "false"))) --8<---------------cut here---------------end--------------->8--- results in an empty (except the header of course) byte-compiled file. I expected the quoted version to compile `(defvar quoted-nil "false")ยด which is what that form evaluates to. When I wrap a defmacro around it and call that macro outside the eval-when-compile: --8<---------------cut here---------------start------------->8--- (eval-when-compile (defmacro ewc-macro (&rest body) (if nil '(defvar macro-t "true") '(defvar macro-nil "false")))) (ewc-macro) --8<---------------cut here---------------end--------------->8--- then I get the expected output in the byte-compiled file, but it seems there must be an easier way to do that. The eval-when-compile in this version suppresses the macro definition itself being byte-compiled of course. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ SD adaptation for Waldorf rackAttack V1.04R1: http://Synth.Stromeko.net/Downloads.html#WaldorfSDada