summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-01-23 08:47:22 +0100
committerAraq <rumpf_a@web.de>2014-01-23 08:47:22 +0100
commitd01ff8994b8805a6558c87f1f58c789e42c93694 (patch)
tree14976ba53ab1c02a227fb2ee1fb119d2616a1f8b /doc
parent3f87326247b142df4eff99a92c6529b33bb79b81 (diff)
downloadNim-d01ff8994b8805a6558c87f1f58c789e42c93694.tar.gz
closure iterators work
Diffstat (limited to 'doc')
-rw-r--r--doc/manual.txt16
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