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: Kim F. Storm
Subject: Re: Building Emacs overflowed pure space
Date: Fri, 21 Jul 2006 10:36:22 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

>     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--
>
> The only flaw of this is that BODY can see the variable --dolist-temp--.
> Practically speaking, it may not ever matter; users are unlikely to
> use that variable by accident.  However, it is cleaner to prevent that
> by using an uninterned symbol, assuming we can get rid of the current
> inefficiency that that causes.

So what about using shorter symbol names than --dolist-temp--
--dotimes-temp--, --cl-dolist-temp-- etc.

And for the "defconst-tmp-var" symbol used in byte-compile-defvar.

E.g use "*" instead of the longer name.

That'll save a few KBytes.


But to follow your suggestion, why don't we just have _one_ generic
uninterned "tmp" symbol for all such uses.

E.g.

(defconst uninterned-tmp (make-symbol "tmp")
  "Uninterned symbol for use in macros.")

And then modify dolist (and friends) to:

(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 uninterned-tmp))
    `(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)))))))


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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