From e1d79d40f2ef41e26b6c529f52023a59acaf0d0e Mon Sep 17 00:00:00 2001 From: Judd Date: Sat, 21 Dec 2019 15:06:32 +0800 Subject: [PATCH] update documentation for `closureScope` and `capture` (#12886) --- doc/manual.rst | 3 ++- lib/system.nim | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/manual.rst b/doc/manual.rst index 9ce67ec45..bce51e3fd 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -3521,7 +3521,8 @@ Creating closures in loops Since closures capture local variables by reference it is often not wanted behavior inside loop bodies. See `closureScope -`_ for details on how to change this behavior. +`_ and `capture +`_ for details on how to change this behavior. Anonymous Procs --------------- diff --git a/lib/system.nim b/lib/system.nim index 559f5fb89..05029b9d7 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -4395,7 +4395,12 @@ when defined(nimNoNilSeqs2): template closureScope*(body: untyped): untyped = ## Useful when creating a closure in a loop to capture local loop variables by - ## their current iteration values. Example: + ## their current iteration values. + ## + ## Note: This template may not work in some cases, use + ## `capture `_ instead. + ## + ## Example: ## ## .. code-block:: Nim ## var myClosure : proc()