From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: [h-e-w] info Date: Tue, 01 Apr 2008 19:21:23 +0200 Message-ID: <47F26F13.1070208@gmail.com> References: <47F1680F.20606@tiscali.co.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1207070638 10917 80.91.229.12 (1 Apr 2008 17:23:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Apr 2008 17:23:58 +0000 (UTC) Cc: Emacs Devel To: David R Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 01 19:24:29 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JgkDU-00070e-LG for ged-emacs-devel@m.gmane.org; Tue, 01 Apr 2008 19:24:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgkCr-0001iD-TL for ged-emacs-devel@m.gmane.org; Tue, 01 Apr 2008 13:23:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JgkAs-0000hb-Mx for emacs-devel@gnu.org; Tue, 01 Apr 2008 13:21:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JgkAr-0000g2-WB for emacs-devel@gnu.org; Tue, 01 Apr 2008 13:21:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgkAr-0000fr-5j for emacs-devel@gnu.org; Tue, 01 Apr 2008 13:21:29 -0400 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JgkAq-0005S2-EL for emacs-devel@gnu.org; Tue, 01 Apr 2008 13:21:29 -0400 Original-Received: from c83-254-150-27.bredband.comhem.se ([83.254.150.27]:60017 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1JgkAm-0001Ew-5w; Tue, 01 Apr 2008 19:21:26 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 In-Reply-To: <47F1680F.20606@tiscali.co.uk> X-Antivirus: avast! (VPS 080331-0, 2008-03-31), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.150.27 X-Scan-Result: No virus found in message 1JgkAm-0001Ew-5w. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1JgkAm-0001Ew-5w 62d2fccfb769ad65076cb86fa8d303e8 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:94130 Archived-At: David sent this as a bug report to h-e-w (because bug reports for my patched versions may be sent there). David, I think what you want is some better explanations for those points you have marked below, right? David R wrote: > File: elisp, Node: Surprising Local Vars, Next: Eval During Expansion, > Prev: Argument Evaluation, Up: Problems with Macros > > 13.6.3 Local Variables in Macro Expansions > ------------------------------------------ > > In the previous section, the definition of `for' was fixed as follows > to make the expansion evaluate the macro arguments the proper number of > times: > > (defmacro for (var from init to final do &rest body) > "Execute a simple for loop: (for i from 1 to 10 do (print i))." > `(let ((,var ,init) > (max ,final)) > (while (<= ,var max) > ,@body > (inc ,var)))) > > The new definition of `for' has a new problem: it introduces a local > variable named `max' which the user does not expect. This causes > trouble in examples such as the following: > > (let ((max 0)) > (for x from 0 to 10 do > (let ((this (frob x))) > (if (< max this) > (setq max this))))) > > The references to `max' inside the body of the `for', which are > supposed to refer to the user's binding of `max', really access the > binding made by `for'. > > The way to correct this is to use an uninterned symbol instead of > `max' (*note Creating Symbols::). The uninterned symbol can be bound > and referred to just like any other symbol, but since it is created by > `for', we know that it cannot already appear in the user's program. > Since it is not interned, there is no way the user can put it into the > program later. It will never appear anywhere except where put by > `for'. Here is a definition of `for' that works this way: > > (defmacro for (var from init to final do &rest body) > "Execute a simple for loop: (for i from 1 to 10 do (print i))." > (let ((tempvar (make-symbol "max"))) > `(let ((,var ,init) > (,tempvar ,final)) > (while (<= ,var ,tempvar) > ,@body > (inc ,var))))) > > This creates an uninterned symbol named `max' and puts it in the > ^^^^^ > tempvar > > expansion instead of the usual interned symbol `max' that appears in > expressions ordinarily. > > > File: elisp, Node: Compiling Macros, Next: Defining Macros, Prev: > Expansion, Up: Macros > > 13.3 Macros and Byte Compilation > ================================ > > You might ask why we take the trouble to compute an expansion for a > macro and then evaluate the expansion. Why not have the macro body > produce the desired results directly? The reason has to do with > compilation. > > When a macro call appears in a Lisp program being compiled, the Lisp > compiler calls the macro definition just as the interpreter would, and > receives an expansion. But instead of evaluating this expansion, it > compiles the expansion as if it had appeared directly in the program. > As a result, the compiled code produces the value and side effects > ^^^^^ value of what? > > intended for the macro, but executes at full compiled speed. This would > ^^^ as the expansion of the macro, or passed to the macro? > > not work if the macro body computed the value and side effects > ^^^^^^^^ computed = evaluated or expanded? > > itself--they would be computed at compile time, which is not useful. > ^^^^^^^^ > > In order for compilation of macro calls to work, the macros must > already be defined in Lisp when the calls to them are compiled. The > compiler has a special feature to help you do this: if a file being > compiled contains a `defmacro' form, the macro is defined temporarily > for the rest of the compilation of that file. To make this feature > work, you must put the `defmacro' in the same file where it is used, > and before its first use. > > Byte-compiling a file executes any `require' calls at top-level in > the file. This is in case the file needs the required packages for > proper compilation. One way to ensure that necessary macro definitions > are available during compilation is to require the files that define > them (*note Named Features::). To avoid loading the macro definition > files when someone _runs_ the compiled program, write > `eval-when-compile' around the `require' calls (*note Eval During > Compile::). > > > > > > > In GNU Emacs 22.0.990.1 (i386-mingw-nt5.1.2600) > of 2007-05-23 on LENNART-69DE564 (patched) > Windowing system distributor `Microsoft Corp.', version 5.1.2600 > configured using `configure --with-gcc (3.4) --cflags -Ic:/g/include' > > Important settings: > value of $LC_ALL: nil > value of $LC_COLLATE: nil > value of $LC_CTYPE: nil > value of $LC_MESSAGES: nil > value of $LC_MONETARY: nil > value of $LC_NUMERIC: nil > value of $LC_TIME: nil > value of $LANG: ENG > locale-coding-system: cp1252 > default-enable-multibyte-characters: t > > Major mode: Info > > Minor modes in effect: > server-mode: t > show-paren-mode: t > encoded-kbd-mode: t > tooltip-mode: t > tool-bar-mode: t > mouse-wheel-mode: t > noticeable-minibuffer-prompts-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-mode: t > unify-8859-on-encoding-mode: t > utf-translate-cjk-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t > > Recent input: > > > > > > > > > > > > > > > > > > > SPC [ SPC > ] > > > > > > > > > > [ SPC ] SPC > > > > > > > C-x > a M-w > > > > > > > ug> > > Recent messages: > (No files need saving) > nil > call-interactively: End of buffer > call-interactively: Beginning of buffer > Mark set [2 times] > (2 3) > (1 2 3 4 2 3) [2 times] > (1 (2 3) 4 (2 3)) > (2 3) > Loading emacsbug...done > *** E-Mail body has been placed on clipboard, please paste them here! *** > > >