diff options
| author | Juri Linkov | 2018-04-28 23:20:33 +0300 |
|---|---|---|
| committer | Juri Linkov | 2018-04-28 23:20:33 +0300 |
| commit | f4eeb0f5ae448db0f064f6305ab0bc0c3bae071a (patch) | |
| tree | 375951dfe30538df200f6650b9bf178aadd3c803 | |
| parent | 0b3bc05d15c32ffa134347896c9b9fcff89225ab (diff) | |
| download | emacs-f4eeb0f5ae448db0f064f6305ab0bc0c3bae071a.tar.gz emacs-f4eeb0f5ae448db0f064f6305ab0bc0c3bae071a.zip | |
* lisp/subr.el (dotimes): Deprecate RESULT field. (Bug#16206)
* 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.
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 21 | ||||
| -rw-r--r-- | doc/lispref/control.texi | 3 | ||||
| -rw-r--r-- | doc/misc/cl.texi | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 2 | ||||
| -rw-r--r-- | test/lisp/filenotify-tests.el | 10 | ||||
| -rw-r--r-- | test/src/emacs-module-tests.el | 5 |
6 files changed, 25 insertions, 20 deletions
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index b672d7cbeed..4d514aab1cf 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi | |||
| @@ -11013,9 +11013,8 @@ The @code{dotimes} macro is similar to @code{dolist}, except that it | |||
| 11013 | loops a specific number of times. | 11013 | loops a specific number of times. |
| 11014 | 11014 | ||
| 11015 | The first argument to @code{dotimes} is assigned the numbers 0, 1, 2 | 11015 | The first argument to @code{dotimes} is assigned the numbers 0, 1, 2 |
| 11016 | and so forth each time around the loop, and the value of the third | 11016 | and so forth each time around the loop. You need to provide the value |
| 11017 | argument is returned. You need to provide the value of the second | 11017 | of the second argument, which is how many times the macro loops. |
| 11018 | argument, which is how many times the macro loops. | ||
| 11019 | 11018 | ||
| 11020 | @need 1250 | 11019 | @need 1250 |
| 11021 | For example, the following binds the numbers from 0 up to, but not | 11020 | 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.) | |||
| 11027 | @smallexample | 11026 | @smallexample |
| 11028 | @group | 11027 | @group |
| 11029 | (let (value) ; otherwise a value is a void variable | 11028 | (let (value) ; otherwise a value is a void variable |
| 11030 | (dotimes (number 3 value) | 11029 | (dotimes (number 3) |
| 11031 | (setq value (cons number value)))) | 11030 | (setq value (cons number value))) |
| 11031 | value) | ||
| 11032 | 11032 | ||
| 11033 | @result{} (2 1 0) | 11033 | @result{} (2 1 0) |
| 11034 | @end group | 11034 | @end group |
| 11035 | @end smallexample | 11035 | @end smallexample |
| 11036 | 11036 | ||
| 11037 | @noindent | 11037 | @noindent |
| 11038 | @code{dotimes} returns @code{value}, so the way to use | 11038 | The way to use @code{dotimes} is to operate on some expression |
| 11039 | @code{dotimes} is to operate on some expression @var{number} number of | 11039 | @var{number} number of times and then return the result, either as |
| 11040 | times and then return the result, either as a list or an atom. | 11040 | a list or an atom. |
| 11041 | 11041 | ||
| 11042 | @need 1250 | 11042 | @need 1250 |
| 11043 | Here is an example of a @code{defun} that uses @code{dotimes} to add | 11043 | 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. | |||
| 11048 | (defun triangle-using-dotimes (number-of-rows) | 11048 | (defun triangle-using-dotimes (number-of-rows) |
| 11049 | "Using `dotimes', add up the number of pebbles in a triangle." | 11049 | "Using `dotimes', add up the number of pebbles in a triangle." |
| 11050 | (let ((total 0)) ; otherwise a total is a void variable | 11050 | (let ((total 0)) ; otherwise a total is a void variable |
| 11051 | (dotimes (number number-of-rows total) | 11051 | (dotimes (number number-of-rows) |
| 11052 | (setq total (+ total (1+ number)))))) | 11052 | (setq total (+ total (1+ number)))) |
| 11053 | total)) | ||
| 11053 | 11054 | ||
| 11054 | (triangle-using-dotimes 4) | 11055 | (triangle-using-dotimes 4) |
| 11055 | @end group | 11056 | @end group |
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index adec632da6a..42aa3c9888d 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi | |||
| @@ -703,7 +703,8 @@ This construct executes @var{body} once for each integer from 0 | |||
| 703 | (inclusive) to @var{count} (exclusive), binding the variable @var{var} | 703 | (inclusive) to @var{count} (exclusive), binding the variable @var{var} |
| 704 | to the integer for the current iteration. Then it returns the value | 704 | to the integer for the current iteration. Then it returns the value |
| 705 | of evaluating @var{result}, or @code{nil} if @var{result} is omitted. | 705 | of evaluating @var{result}, or @code{nil} if @var{result} is omitted. |
| 706 | Here is an example of using @code{dotimes} to do something 100 times: | 706 | Use of @var{result} is deprecated. Here is an example of using |
| 707 | @code{dotimes} to do something 100 times: | ||
| 707 | 708 | ||
| 708 | @example | 709 | @example |
| 709 | (dotimes (i 100) | 710 | (dotimes (i 100) |
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index bf85b00e937..5ae0faf2554 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi | |||
| @@ -1712,9 +1712,9 @@ but surrounds the loop with an implicit @code{nil} block. | |||
| 1712 | The body is executed with @var{var} bound to the integers | 1712 | The body is executed with @var{var} bound to the integers |
| 1713 | from zero (inclusive) to @var{count} (exclusive), in turn. Then | 1713 | from zero (inclusive) to @var{count} (exclusive), in turn. Then |
| 1714 | @c FIXME lispref does not state this part explicitly, could move this there. | 1714 | @c FIXME lispref does not state this part explicitly, could move this there. |
| 1715 | the @code{result} form is evaluated with @var{var} bound to the total | 1715 | the @var{result} form is evaluated with @var{var} bound to the total |
| 1716 | number of iterations that were done (i.e., @code{(max 0 @var{count})}) | 1716 | number of iterations that were done (i.e., @code{(max 0 @var{count})}) |
| 1717 | to get the return value for the loop form. | 1717 | to get the return value for the loop form. Use of @var{result} is deprecated. |
| 1718 | @end defmac | 1718 | @end defmac |
| 1719 | 1719 | ||
| 1720 | @defmac cl-do-symbols (var [obarray [result]]) forms@dots{} | 1720 | @defmac cl-do-symbols (var [obarray [result]]) forms@dots{} |
diff --git a/lisp/subr.el b/lisp/subr.el index dd51539fa1e..9f6cade0f71 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -223,7 +223,7 @@ Then evaluate RESULT to get return value, default nil. | |||
| 223 | "Loop a certain number of times. | 223 | "Loop a certain number of times. |
| 224 | Evaluate BODY with VAR bound to successive integers running from 0, | 224 | Evaluate BODY with VAR bound to successive integers running from 0, |
| 225 | inclusive, to COUNT, exclusive. Then evaluate RESULT to get | 225 | inclusive, to COUNT, exclusive. Then evaluate RESULT to get |
| 226 | the return value (nil if RESULT is omitted). | 226 | the return value (nil if RESULT is omitted). Its use is deprecated. |
| 227 | 227 | ||
| 228 | \(fn (VAR COUNT [RESULT]) BODY...)" | 228 | \(fn (VAR COUNT [RESULT]) BODY...)" |
| 229 | (declare (indent 1) (debug dolist)) | 229 | (declare (indent 1) (debug dolist)) |
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el index 219fa746119..56403f43092 100644 --- a/test/lisp/filenotify-tests.el +++ b/test/lisp/filenotify-tests.el | |||
| @@ -1129,14 +1129,16 @@ delivered." | |||
| 1129 | ;; w32notify fires both `deleted' and `renamed' events. | 1129 | ;; w32notify fires both `deleted' and `renamed' events. |
| 1130 | ((string-equal (file-notify--test-library) "w32notify") | 1130 | ((string-equal (file-notify--test-library) "w32notify") |
| 1131 | (let (r) | 1131 | (let (r) |
| 1132 | (dotimes (_i n r) | 1132 | (dotimes (_i n) |
| 1133 | (setq r (append '(deleted renamed) r))))) | 1133 | (setq r (append '(deleted renamed) r))) |
| 1134 | r)) | ||
| 1134 | ;; cygwin fires `changed' and `deleted' events, sometimes | 1135 | ;; cygwin fires `changed' and `deleted' events, sometimes |
| 1135 | ;; in random order. | 1136 | ;; in random order. |
| 1136 | ((eq system-type 'cygwin) | 1137 | ((eq system-type 'cygwin) |
| 1137 | (let (r) | 1138 | (let (r) |
| 1138 | (dotimes (_i n (cons :random r)) | 1139 | (dotimes (_i n) |
| 1139 | (setq r (append '(changed deleted) r))))) | 1140 | (setq r (append '(changed deleted) r))) |
| 1141 | (cons :random r))) | ||
| 1140 | (t (make-list n 'renamed))) | 1142 | (t (make-list n 'renamed))) |
| 1141 | (let ((source-file-list source-file-list) | 1143 | (let ((source-file-list source-file-list) |
| 1142 | (target-file-list target-file-list)) | 1144 | (target-file-list target-file-list)) |
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el index 8b6328d35af..9ef5a47b159 100644 --- a/test/src/emacs-module-tests.el +++ b/test/src/emacs-module-tests.el | |||
| @@ -138,8 +138,9 @@ changes." | |||
| 138 | 138 | ||
| 139 | (defun multiply-string (s n) | 139 | (defun multiply-string (s n) |
| 140 | (let ((res "")) | 140 | (let ((res "")) |
| 141 | (dotimes (i n res) | 141 | (dotimes (i n) |
| 142 | (setq res (concat res s))))) | 142 | (setq res (concat res s))) |
| 143 | res)) | ||
| 143 | 144 | ||
| 144 | (ert-deftest mod-test-globref-make-test () | 145 | (ert-deftest mod-test-globref-make-test () |
| 145 | (let ((mod-str (mod-test-globref-make)) | 146 | (let ((mod-str (mod-test-globref-make)) |