diff options
author | Araq <rumpf_a@web.de> | 2014-01-23 08:47:22 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-23 08:47:22 +0100 |
commit | d01ff8994b8805a6558c87f1f58c789e42c93694 (patch) | |
tree | 14976ba53ab1c02a227fb2ee1fb119d2616a1f8b /doc | |
parent | 3f87326247b142df4eff99a92c6529b33bb79b81 (diff) | |
download | Nim-d01ff8994b8805a6558c87f1f58c789e42c93694.tar.gz |
closure iterators work
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.txt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/doc/manual.txt b/doc/manual.txt index 9f84bc951..faf62dcee 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2837,8 +2837,22 @@ The builtin ``system.finished`` can be used to determine if an iterator has finished its operation; no exception is raised on an attempt to invoke an iterator that has already finished its work. -One always has to +Closure iterators are *resumable functions* and so one has to provide the +arguments to every call. To get around this limitation one can capture +parameters of an outer factory proc: +.. code-block:: nimrod + proc mycount(a, b: int): iterator (): int = + return iterator (): int = + var x = a + while x <= b: + yield x + inc x + + let foo = mycount 1, 4 + + for f in foo(): + echo f Type sections |