emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building Emacs overflowed pure space


From: David Kastrup
Subject: Re: Building Emacs overflowed pure space
Date: Thu, 20 Jul 2006 11:58:04 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

address@hidden (Kim F. Storm) writes:

> Richard Stallman <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]