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: Re: eval-when-compile Date: Fri, 27 Jul 2012 19:50:58 +0200 Organization: Linux Private Site Message-ID: <87y5m5rt31.fsf@Rainer.invalid> References: <871ujx94qo.fsf@Rainer.invalid> <871ujxd8in.fsf@kuiper.lan.informatimago.com> 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 1343411478 23594 80.91.229.3 (27 Jul 2012 17:51:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Jul 2012 17:51:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 27 19:51:18 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 1Suoh4-0002ba-9o for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2012 19:51:18 +0200 Original-Received: from localhost ([::1]:36621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Suoh3-0004wa-Ng for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2012 13:51:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Suoh1-0004wV-IC for emacs-devel@gnu.org; Fri, 27 Jul 2012 13:51:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Suoh0-0001UT-7I for emacs-devel@gnu.org; Fri, 27 Jul 2012 13:51:15 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:55210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Suoh0-0001UP-0K for emacs-devel@gnu.org; Fri, 27 Jul 2012 13:51:14 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Suogx-0002Ws-Hm for emacs-devel@gnu.org; Fri, 27 Jul 2012 19:51:11 +0200 Original-Received: from pd9eb52bb.dip.t-dialin.net ([217.235.82.187]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jul 2012 19:51:11 +0200 Original-Received: from Stromeko by pd9eb52bb.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jul 2012 19:51:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: pd9eb52bb.dip.t-dialin.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:qwGFW5FKzVRSqyAxCMyvFTmkAwo= 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:151926 Archived-At: Pascal J. Bourguignon writes: > C-h f eval-when-compile RET > > Like `progn', but evaluates the body at compile time if you're compiling. > Thus, the result of the body appears to the compiler as a quoted constant. > In interpreted code, this is entirely equivalent to `progn'. > > What more can I add? I read that. It doesn't seem to work that way or has some strings attached that aren't obvious to me from the documentation. > The above source will evaluate, when you compile the file: > > (defvar unquoted-t "true") > '(defvar quoted-nil "false") No. They will evaluate to unquoted-t (defvar quoted-nil "false") The unquoted variant was only there to check if maybe there's another `(quote …)´ snuck in. I expected the defvar form to compile, but it doesn't. > When you load the file, it won't evaluate anything. Actually they will evaluate to the very same thing, per the definition of eval-when-compile. It's easy enough to see that this part is working as advertised. > Here, you're defining a macro at compilation time. When compiling this > file, the macro is known and (ewc-macro) expands to (defvar macro-nil > "false") so that's compiled into the elc file, and that's the only thing > that's loaded. Yes, that is working as expected, however I don't like the clutter that it produces. > If you try to load the .el file directly, then the macro is not defined, > and you're trying to call a function named (ewc-macro) which will fail. Again, the macro will be defined at load time and expanded from the `(ewc-macro)´ form. There'd be a lot of broken code in Emacs if that wasn't working. > Now indeed, if you have decisions to make at compilation time, you need > to define variables and functions at compilation time to compute those > decisions. What I'm actually trying to do is providing compatibility definitions for other versions of Emacs. That works fine as long as I only need to compute different values at compile time (as documented in the manual). It doesn't work when I can do a `(defalias …)´ for one version of Emacs, but need a `(defun …)´ for another. It can all be solved one way or the other by adding macros to the mix, but my question still hasn't been answered: why does it not work with eval-when-compile? Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ SD adaptation for Waldorf Blofeld V1.15B11: http://Synth.Stromeko.net/Downloads.html#WaldorfSDada