From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Building Emacs overflowed pure space Date: Thu, 20 Jul 2006 11:58:04 +0200 Message-ID: <857j28egyb.fsf@lola.goethe.zz> References: <7dbe73ed0607180138x35e9d9bft3e42f20cb369795c@mail.gmail.com> <200607181929.k6IJTZN9028639@jane.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1153389526 10791 80.91.229.2 (20 Jul 2006 09:58:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Jul 2006 09:58:46 +0000 (UTC) Cc: teirllm@dms.auburn.edu, rms@gnu.org, ralphm@members.fsf.org, emacs-devel@gnu.org, YAMAMOTO Mitsuharu , mathias.dahl@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 20 11:58:43 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G3VIe-00037o-8R for ged-emacs-devel@m.gmane.org; Thu, 20 Jul 2006 11:58:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G3VId-0004gd-MB for ged-emacs-devel@m.gmane.org; Thu, 20 Jul 2006 05:58:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G3VIS-0004fH-4s for emacs-devel@gnu.org; Thu, 20 Jul 2006 05:58:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G3VIR-0004eI-FI for emacs-devel@gnu.org; Thu, 20 Jul 2006 05:58:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G3VIR-0004e1-7z for emacs-devel@gnu.org; Thu, 20 Jul 2006 05:58:19 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G3VIZ-0001nJ-6S; Thu, 20 Jul 2006 05:58:27 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1G3VIE-0003eu-Eh; Thu, 20 Jul 2006 05:58:06 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id BBBAE1C4D3B5; Thu, 20 Jul 2006 11:58:04 +0200 (CEST) Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: (Kim F. Storm's message of "Thu, 20 Jul 2006 11:34:31 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:57373 Archived-At: storm@cua.dk (Kim F. Storm) writes: > Richard Stallman writes: > >> I see no good reason why each expansion of `dolist' should use a >> different symbol. Maybe we can arrange to use one symbol over and >> over again. Does this work? > > I'm getting confused now (the summer heat here is draining). > > Why is make-symbol used in dolist at all? The benefit seems > infinitesimal to me, and in particular if you now suggest that we > should intern another variable just to hold the uninterned symbol. > > > Current version: > > (defmacro dolist (spec &rest body) > "Loop over a list. > Evaluate BODY with VAR bound to each car from LIST, in turn. > Then evaluate RESULT to get return value, default nil. > > \(fn (VAR LIST [RESULT]) BODY...)" > (declare (indent 1) (debug ((symbolp form &optional form) body))) > (let ((temp (make-symbol "--dolist-temp--"))) > `(let ((,temp ,(nth 1 spec)) > ,(car spec)) > (while ,temp > (setq ,(car spec) (car ,temp)) > (setq ,temp (cdr ,temp)) > ,@body) > ,@(if (cdr (cdr spec)) > `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) > > > Why isn't the following version just as good? > > (defmacro dolist (spec &rest body) > "Loop over a list. > Evaluate BODY with VAR bound to each car from LIST, in turn. > Then evaluate RESULT to get return value, default nil. > > \(fn (VAR LIST [RESULT]) BODY...)" > (declare (indent 1) (debug ((symbolp form &optional form) body))) > `(let ((--dolist-temp-- ,(nth 1 spec)) > ,(car spec)) > (while --dolist-temp-- > (setq ,(car spec) (car --dolist-temp--)) > (setq --dolist-temp-- (cdr --dolist-temp--)) > ,@body) > ,@(if (cdr (cdr spec)) > `((setq ,(car spec) nil) ,@(cdr (cdr spec)))))) (dolist (i '(1 2)) (dolist (j '(3 4)) [...])) >> (defvar dolist-temp-var nil) >> >> (defmacro dolist (spec &rest body) >> "Loop over a list. >> Evaluate BODY with VAR bound to each car from LIST, in turn. >> Then evaluate RESULT to get return value, default nil. >> >> \(fn (VAR LIST [RESULT]) BODY...)" >> (declare (indent 1) (debug ((symbolp form &optional form) body))) >> (unless dolist-temp-var >> (setq dolist-temp-var (make-symbol "--dolist-temp--"))) >> (let ((temp dolist-temp-var)) >> `(let ((,temp ,(nth 1 spec)) >> ,(car spec)) >> (while ,temp >> (setq ,(car spec) (car ,temp)) >> (setq ,temp (cdr ,temp)) >> ,@body) >> ,@(if (cdr (cdr spec)) >> `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) This version does not suffer the same problem since the macro is exited before a nested dolist is _expanded_ in a similar way. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum