diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-10 13:59:19 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-10 13:59:19 -0300 |
| commit | d2a9b4ffb86de29a201843edddfc0153a1846f96 (patch) | |
| tree | 983ad04e90e07a84f8acde0be917d6940367f53e | |
| parent | f39e8c06d61078467b3f32499728ed4e9b7b06bc (diff) | |
| download | lua-d2a9b4ffb86de29a201843edddfc0153a1846f96.tar.gz lua-d2a9b4ffb86de29a201843edddfc0153a1846f96.tar.bz2 lua-d2a9b4ffb86de29a201843edddfc0153a1846f96.zip | |
Detail in the manual
More precision describing the variables that won't be closed if a
coroutine yields forever.
| -rw-r--r-- | manual/manual.of | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/manual/manual.of b/manual/manual.of index fd49b404..725b12ad 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -1553,9 +1553,11 @@ interrupt the respective method, | |||
| 1553 | but are otherwise ignored; | 1553 | but are otherwise ignored; |
| 1554 | the error reported is the original one. | 1554 | the error reported is the original one. |
| 1555 | 1555 | ||
| 1556 | If a coroutine yields inside a block and is never resumed again, | 1556 | If a coroutine yields and is never resumed again, |
| 1557 | the variables visible at that block will never go out of scope, | 1557 | some variables may never go out of scope, |
| 1558 | and therefore they will never be closed. | 1558 | and therefore they will never be closed. |
| 1559 | (These variables are the ones created inside the coroutine | ||
| 1560 | and in scope at the point where the coroutine yielded.) | ||
| 1559 | Similarly, if a coroutine ends with an error, | 1561 | Similarly, if a coroutine ends with an error, |
| 1560 | it does not unwind its stack, | 1562 | it does not unwind its stack, |
| 1561 | so it does not close any variable. | 1563 | so it does not close any variable. |
| @@ -2245,9 +2247,9 @@ Consider the following example: | |||
| 2245 | @verbatim{ | 2247 | @verbatim{ |
| 2246 | a = {} | 2248 | a = {} |
| 2247 | local x = 20 | 2249 | local x = 20 |
| 2248 | for i=1,10 do | 2250 | for i = 1, 10 do |
| 2249 | local y = 0 | 2251 | local y = 0 |
| 2250 | a[i] = function () y=y+1; return x+y end | 2252 | a[i] = function () y = y + 1; return x + y end |
| 2251 | end | 2253 | end |
| 2252 | } | 2254 | } |
| 2253 | The loop creates ten closures | 2255 | The loop creates ten closures |
| @@ -6815,7 +6817,6 @@ A value of @true as a fourth, optional argument @id{plain} | |||
| 6815 | turns off the pattern matching facilities, | 6817 | turns off the pattern matching facilities, |
| 6816 | so the function does a plain @Q{find substring} operation, | 6818 | so the function does a plain @Q{find substring} operation, |
| 6817 | with no characters in @id{pattern} being considered magic. | 6819 | with no characters in @id{pattern} being considered magic. |
| 6818 | Note that if @id{plain} is given, then @id{init} must be given as well. | ||
| 6819 | 6820 | ||
| 6820 | If the pattern has captures, | 6821 | If the pattern has captures, |
| 6821 | then in a successful match | 6822 | then in a successful match |
