Mercurial > emacs
changeset 27487:9304a93329d1
Remove dotimes, dolist.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 28 Jan 2000 22:42:15 +0000 |
parents | bbeb4a727b7b |
children | f2b4d355b3e2 |
files | lisp/emacs-lisp/cl-macs.el man/cl.texi |
diffstat | 2 files changed, 4 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emacs-lisp/cl-macs.el Fri Jan 28 22:32:28 2000 +0000 +++ b/lisp/emacs-lisp/cl-macs.el Fri Jan 28 22:42:15 2000 +0000 @@ -1122,32 +1122,6 @@ (apply 'append sets))))))) (or (cdr endtest) '(nil))))) -(defmacro dolist (spec &rest body) - "(dolist (VAR LIST [RESULT]) 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." - (let ((temp (gensym "--dolist-temp--"))) - (list 'block nil - (list* 'let (list (list temp (nth 1 spec)) (car spec)) - (list* 'while temp (list 'setq (car spec) (list 'car temp)) - (append body (list (list 'setq temp - (list 'cdr temp))))) - (if (cdr (cdr spec)) - (cons (list 'setq (car spec) nil) (cdr (cdr spec))) - '(nil)))))) - -(defmacro dotimes (spec &rest body) - "(dotimes (VAR COUNT [RESULT]) BODY...): loop a certain number of times. -Evaluate BODY with VAR bound to successive integers from 0, inclusive, -to COUNT, exclusive. Then evaluate RESULT to get return value, default -nil." - (let ((temp (gensym "--dotimes-temp--"))) - (list 'block nil - (list* 'let (list (list temp (nth 1 spec)) (list (car spec) 0)) - (list* 'while (list '< (car spec) temp) - (append body (list (list 'incf (car spec))))) - (or (cdr (cdr spec)) '(nil)))))) - (defmacro do-symbols (spec &rest body) "(dosymbols (VAR [OBARRAY [RESULT]]) BODY...): loop over all symbols. Evaluate BODY with VAR bound to each interned symbol, or to each symbol
--- a/man/cl.texi Fri Jan 28 22:32:28 2000 +0000 +++ b/man/cl.texi Fri Jan 28 22:42:15 2000 +0000 @@ -970,7 +970,7 @@ * Variable Bindings:: `progv', `lexical-let', `flet', `macrolet' * Conditionals:: `case', `typecase' * Blocks and Exits:: `block', `return', `return-from' -* Iteration:: `do', `dotimes', `dolist', `do-symbols' +* Iteration:: `do', `do-symbols' * Loop Facility:: The Common Lisp `loop' macro * Multiple Values:: `values', `multiple-value-bind', etc. @end menu @@ -1924,7 +1924,7 @@ @noindent In this example, the @code{my-dolist} macro is similar to @code{dolist} -(@pxref{Iteration}) except that the variable @code{x} becomes a true +except that the variable @code{x} becomes a true reference onto the elements of the list. The @code{my-dolist} call shown here expands to @@ -2058,7 +2058,7 @@ forms which do create the implicit block. The Common Lisp looping constructs defined by this package, -such as @code{loop} and @code{dolist}, also create implicit blocks +such as @code{loop}, also create implicit blocks just as in Common Lisp. Because they are implemented in terms of Emacs Lisp @code{catch} @@ -2081,7 +2081,7 @@ @defspec return [result] This macro is exactly like @code{(return-from nil @var{result})}. -Common Lisp loops like @code{do} and @code{dolist} implicitly enclose +Common Lisp loops like @code{do} implicitly enclose themselves in @code{nil} blocks. @end defspec @@ -2191,25 +2191,6 @@ @end example @end defspec -@defspec dolist (var list [result]) forms@dots{} -This is a more specialized loop which iterates across the elements -of a list. @var{list} should evaluate to a list; the body @var{forms} -are executed with @var{var} bound to each element of the list in -turn. Finally, the @var{result} form (or @code{nil}) is evaluated -with @var{var} bound to @code{nil} to produce the result returned by -the loop. The loop is surrounded by an implicit @code{nil} block. -@end defspec - -@defspec dotimes (var count [result]) forms@dots{} -This is a more specialized loop which iterates a specified number -of times. The body is executed with @var{var} bound to the integers -from zero (inclusive) to @var{count} (exclusive), in turn. Then -the @code{result} form is evaluated with @var{var} bound to the total -number of iterations that were done (i.e., @code{(max 0 @var{count})}) -to get the return value for the loop form. The loop is surrounded -by an implicit @code{nil} block. -@end defspec - @defspec do-symbols (var [obarray [result]]) forms@dots{} This loop iterates over all interned symbols. If @var{obarray} is specified and is not @code{nil}, it loops over all symbols in