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 /doc/lispintro | |
| 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.
Diffstat (limited to 'doc/lispintro')
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 21 |
1 files changed, 11 insertions, 10 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 |