comparison man/cl.texi @ 27511:ead47a92d9d0

Replace dotimes, dolist, with comment.
author Dave Love <fx@gnu.org>
date Sun, 30 Jan 2000 13:35:25 +0000
parents 9304a93329d1
children c3a446101beb
comparison
equal deleted inserted replaced
27510:a324531e5097 27511:ead47a92d9d0
968 * Assignment:: The `psetq' form 968 * Assignment:: The `psetq' form
969 * Generalized Variables:: `setf', `incf', `push', etc. 969 * Generalized Variables:: `setf', `incf', `push', etc.
970 * Variable Bindings:: `progv', `lexical-let', `flet', `macrolet' 970 * Variable Bindings:: `progv', `lexical-let', `flet', `macrolet'
971 * Conditionals:: `case', `typecase' 971 * Conditionals:: `case', `typecase'
972 * Blocks and Exits:: `block', `return', `return-from' 972 * Blocks and Exits:: `block', `return', `return-from'
973 * Iteration:: `do', `do-symbols' 973 * Iteration:: `do', `dotimes', `dolist', `do-symbols'
974 * Loop Facility:: The Common Lisp `loop' macro 974 * Loop Facility:: The Common Lisp `loop' macro
975 * Multiple Values:: `values', `multiple-value-bind', etc. 975 * Multiple Values:: `values', `multiple-value-bind', etc.
976 @end menu 976 @end menu
977 977
978 @node Assignment, Generalized Variables, Control Structure, Control Structure 978 @node Assignment, Generalized Variables, Control Structure, Control Structure
1922 @result{} (2 3 4 5) 1922 @result{} (2 3 4 5)
1923 @end example 1923 @end example
1924 1924
1925 @noindent 1925 @noindent
1926 In this example, the @code{my-dolist} macro is similar to @code{dolist} 1926 In this example, the @code{my-dolist} macro is similar to @code{dolist}
1927 except that the variable @code{x} becomes a true 1927 (@pxref{Iteration}) except that the variable @code{x} becomes a true
1928 reference onto the elements of the list. The @code{my-dolist} call 1928 reference onto the elements of the list. The @code{my-dolist} call
1929 shown here expands to 1929 shown here expands to
1930 1930
1931 @example 1931 @example
1932 (loop for G1234 on mylist do 1932 (loop for G1234 on mylist do
2056 same name as the function or macro. This does not occur in Emacs 2056 same name as the function or macro. This does not occur in Emacs
2057 Lisp, but this package provides @code{defun*} and @code{defmacro*} 2057 Lisp, but this package provides @code{defun*} and @code{defmacro*}
2058 forms which do create the implicit block. 2058 forms which do create the implicit block.
2059 2059
2060 The Common Lisp looping constructs defined by this package, 2060 The Common Lisp looping constructs defined by this package,
2061 such as @code{loop}, also create implicit blocks 2061 such as @code{loop} and @code{dolist}, also create implicit blocks
2062 just as in Common Lisp. 2062 just as in Common Lisp.
2063 2063
2064 Because they are implemented in terms of Emacs Lisp @code{catch} 2064 Because they are implemented in terms of Emacs Lisp @code{catch}
2065 and @code{throw}, blocks have the same overhead as actual 2065 and @code{throw}, blocks have the same overhead as actual
2066 @code{catch} constructs (roughly two function calls). However, 2066 @code{catch} constructs (roughly two function calls). However,
2079 Otherwise, @code{nil} is returned. 2079 Otherwise, @code{nil} is returned.
2080 @end defspec 2080 @end defspec
2081 2081
2082 @defspec return [result] 2082 @defspec return [result]
2083 This macro is exactly like @code{(return-from nil @var{result})}. 2083 This macro is exactly like @code{(return-from nil @var{result})}.
2084 Common Lisp loops like @code{do} implicitly enclose 2084 Common Lisp loops like @code{do} and @code{dolist} implicitly enclose
2085 themselves in @code{nil} blocks. 2085 themselves in @code{nil} blocks.
2086 @end defspec 2086 @end defspec
2087 2087
2088 @node Iteration, Loop Facility, Blocks and Exits, Control Structure 2088 @node Iteration, Loop Facility, Blocks and Exits, Control Structure
2089 @section Iteration 2089 @section Iteration
2187 z) 2187 z)
2188 ((or (null xp) (null yp)) 2188 ((or (null xp) (null yp))
2189 (nreverse z)) 2189 (nreverse z))
2190 (push (f x y) z)) 2190 (push (f x y) z))
2191 @end example 2191 @end example
2192 @end defspec
2193
2194 @defspec dolist (var list [result]) forms@dots{}
2195 This is a more specialized loop which iterates across the elements
2196 of a list. @var{list} should evaluate to a list; the body @var{forms}
2197 are executed with @var{var} bound to each element of the list in
2198 turn. Finally, the @var{result} form (or @code{nil}) is evaluated
2199 with @var{var} bound to @code{nil} to produce the result returned by
2200 the loop. Unlike with Emacs's built in @code{dolist}, the loop is
2201 surrounded by an implicit @code{nil} block.
2202 @end defspec
2203
2204 @defspec dotimes (var count [result]) forms@dots{}
2205 This is a more specialized loop which iterates a specified number
2206 of times. The body is executed with @var{var} bound to the integers
2207 from zero (inclusive) to @var{count} (exclusive), in turn. Then
2208 the @code{result} form is evaluated with @var{var} bound to the total
2209 number of iterations that were done (i.e., @code{(max 0 @var{count})})
2210 to get the return value for the loop form. Unlike with Emacs's built in
2211 @code{dolist}, the loop is surrounded by an implicit @code{nil} block.
2192 @end defspec 2212 @end defspec
2193 2213
2194 @defspec do-symbols (var [obarray [result]]) forms@dots{} 2214 @defspec do-symbols (var [obarray [result]]) forms@dots{}
2195 This loop iterates over all interned symbols. If @var{obarray} 2215 This loop iterates over all interned symbols. If @var{obarray}
2196 is specified and is not @code{nil}, it loops over all symbols in 2216 is specified and is not @code{nil}, it loops over all symbols in