]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/subr.el (dotimes): Deprecate RESULT field. (Bug#16206)
authorJuri Linkov <juri@linkov.net>
Sat, 28 Apr 2018 20:20:33 +0000 (23:20 +0300)
committerJuri Linkov <juri@linkov.net>
Sat, 28 Apr 2018 20:20:33 +0000 (23:20 +0300)
* doc/lispref/control.texi (Iteration):
* doc/misc/cl.texi (Iteration): Document deprecation of its use.
* doc/lispintro/emacs-lisp-intro.texi (dotimes):
* test/src/emacs-module-tests.el (multiply-string):
* test/lisp/filenotify-tests.el (file-notify-test07-many-events):
Place RESULT field after the form.

doc/lispintro/emacs-lisp-intro.texi
doc/lispref/control.texi
doc/misc/cl.texi
lisp/subr.el
test/lisp/filenotify-tests.el
test/src/emacs-module-tests.el

index b672d7cbeed5c59ae5104704741f9cc3a731e3e4..4d514aab1cfc7b4abf88655db83003d1d125c6c1 100644 (file)
@@ -11013,9 +11013,8 @@ The @code{dotimes} macro is similar to @code{dolist}, except that it
 loops a specific number of times.
 
 The first argument to @code{dotimes} is assigned the numbers 0, 1, 2
-and so forth each time around the loop, and the value of the third
-argument is returned.  You need to provide the value of the second
-argument, which is how many times the macro loops.
+and so forth each time around the loop.  You need to provide the value
+of the second argument, which is how many times the macro loops.
 
 @need 1250
 For example, the following binds the numbers from 0 up to, but not
@@ -11027,17 +11026,18 @@ three numbers in all, starting with zero as the first number.)
 @smallexample
 @group
 (let (value)      ; otherwise a value is a void variable
-  (dotimes (number 3 value)
-    (setq value (cons number value))))
+  (dotimes (number 3)
+    (setq value (cons number value)))
+  value)
 
 @result{} (2 1 0)
 @end group
 @end smallexample
 
 @noindent
-@code{dotimes} returns @code{value}, so the way to use
-@code{dotimes} is to operate on some expression @var{number} number of
-times and then return the result, either as a list or an atom.
+The way to use @code{dotimes} is to operate on some expression
+@var{number} number of times and then return the result, either as
+a list or an atom.
 
 @need 1250
 Here is an example of a @code{defun} that uses @code{dotimes} to add
@@ -11048,8 +11048,9 @@ up the number of pebbles in a triangle.
 (defun triangle-using-dotimes (number-of-rows)
   "Using `dotimes', add up the number of pebbles in a triangle."
 (let ((total 0))  ; otherwise a total is a void variable
-  (dotimes (number number-of-rows total)
-    (setq total (+ total (1+ number))))))
+  (dotimes (number number-of-rows)
+    (setq total (+ total (1+ number))))
+  total))
 
 (triangle-using-dotimes 4)
 @end group
index adec632da6a905993781faa2304b1e16fee29c27..42aa3c9888df92b295f5e4920d0b65470587d406 100644 (file)
@@ -703,7 +703,8 @@ This construct executes @var{body} once for each integer from 0
 (inclusive) to @var{count} (exclusive), binding the variable @var{var}
 to the integer for the current iteration.  Then it returns the value
 of evaluating @var{result}, or @code{nil} if @var{result} is omitted.
-Here is an example of using @code{dotimes} to do something 100 times:
+Use of @var{result} is deprecated.  Here is an example of using
+@code{dotimes} to do something 100 times:
 
 @example
 (dotimes (i 100)
index bf85b00e937903997ee4344eafb53176a35e5508..5ae0faf2554e1e3b961af94dc38c4fcb1cac56b0 100644 (file)
@@ -1712,9 +1712,9 @@ but surrounds the loop with an implicit @code{nil} block.
 The body is executed with @var{var} bound to the integers
 from zero (inclusive) to @var{count} (exclusive), in turn.  Then
 @c FIXME lispref does not state this part explicitly, could move this there.
-the @code{result} form is evaluated with @var{var} bound to the total
+the @var{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.
+to get the return value for the loop form.  Use of @var{result} is deprecated.
 @end defmac
 
 @defmac cl-do-symbols (var [obarray [result]]) forms@dots{}
index dd51539fa1e3b98d1e7b3020e259fded91af9ec5..9f6cade0f71ab2c845ee41a353786dbefbeb4d75 100644 (file)
@@ -223,7 +223,7 @@ Then evaluate RESULT to get return value, default nil.
   "Loop a certain number of times.
 Evaluate BODY with VAR bound to successive integers running from 0,
 inclusive, to COUNT, exclusive.  Then evaluate RESULT to get
-the return value (nil if RESULT is omitted).
+the return value (nil if RESULT is omitted).  Its use is deprecated.
 
 \(fn (VAR COUNT [RESULT]) BODY...)"
   (declare (indent 1) (debug dolist))
index 219fa746119dd6871b56ed5b24140f3757827174..56403f430924c937b525287245fa38b6272b4397 100644 (file)
@@ -1129,14 +1129,16 @@ delivered."
             ;; w32notify fires both `deleted' and `renamed' events.
             ((string-equal (file-notify--test-library) "w32notify")
              (let (r)
-               (dotimes (_i n r)
-                 (setq r (append '(deleted renamed) r)))))
+               (dotimes (_i n)
+                 (setq r (append '(deleted renamed) r)))
+               r))
             ;; cygwin fires `changed' and `deleted' events, sometimes
             ;; in random order.
             ((eq system-type 'cygwin)
              (let (r)
-               (dotimes (_i n (cons :random r))
-                 (setq r (append '(changed deleted) r)))))
+               (dotimes (_i n)
+                 (setq r (append '(changed deleted) r)))
+               (cons :random r)))
             (t (make-list n 'renamed)))
           (let ((source-file-list source-file-list)
                 (target-file-list target-file-list))
index 8b6328d35af0cec8e95a8a496a52a088b0ad1703..9ef5a47b159d9870f486581c20f9ffa10f2896ed 100644 (file)
@@ -138,8 +138,9 @@ changes."
 
 (defun multiply-string (s n)
   (let ((res ""))
-    (dotimes (i n res)
-      (setq res (concat res s)))))
+    (dotimes (i n)
+      (setq res (concat res s)))
+    res))
 
 (ert-deftest mod-test-globref-make-test ()
   (let ((mod-str (mod-test-globref-make))