diff options
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/manual/manual.of b/manual/manual.of index 5f265708..cf44b4f2 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -286,7 +286,7 @@ Lua also offers a system of @emph{warnings} @seeF{warn}. | |||
286 | Unlike errors, warnings do not interfere | 286 | Unlike errors, warnings do not interfere |
287 | in any way with program execution. | 287 | in any way with program execution. |
288 | They typically only generate a message to the user, | 288 | They typically only generate a message to the user, |
289 | although this behavior can be adapted from C @see{lua_setwarnf}. | 289 | although this behavior can be adapted from C @seeC{lua_setwarnf}. |
290 | 290 | ||
291 | } | 291 | } |
292 | 292 | ||
@@ -835,6 +835,9 @@ In case of normal termination, | |||
835 | plus any values returned by the coroutine main function. | 835 | plus any values returned by the coroutine main function. |
836 | In case of errors, @Lid{coroutine.resume} returns @false | 836 | In case of errors, @Lid{coroutine.resume} returns @false |
837 | plus the error object. | 837 | plus the error object. |
838 | In this case, the coroutine does not unwind its stack, | ||
839 | so that it is possible to inspect it after the error | ||
840 | with the debug API. | ||
838 | 841 | ||
839 | A coroutine yields by calling @Lid{coroutine.yield}. | 842 | A coroutine yields by calling @Lid{coroutine.yield}. |
840 | When a coroutine yields, | 843 | When a coroutine yields, |
@@ -858,8 +861,10 @@ go as extra arguments to @Lid{coroutine.resume}. | |||
858 | @Lid{coroutine.wrap} returns all the values returned by @Lid{coroutine.resume}, | 861 | @Lid{coroutine.wrap} returns all the values returned by @Lid{coroutine.resume}, |
859 | except the first one (the boolean error code). | 862 | except the first one (the boolean error code). |
860 | Unlike @Lid{coroutine.resume}, | 863 | Unlike @Lid{coroutine.resume}, |
861 | @Lid{coroutine.wrap} does not catch errors; | 864 | the function created by @Lid{coroutine.wrap} |
862 | any error is propagated to the caller. | 865 | propagates any error to the caller. |
866 | In this case, | ||
867 | the function also kills the coroutine @seeF{coroutine.kill}. | ||
863 | 868 | ||
864 | As an example of how coroutines work, | 869 | As an example of how coroutines work, |
865 | consider the following code: | 870 | consider the following code: |
@@ -1534,8 +1539,15 @@ the other pending closing methods will still be called. | |||
1534 | If a coroutine yields inside a block and is never resumed again, | 1539 | If a coroutine yields inside a block and is never resumed again, |
1535 | the variables visible at that block will never go out of scope, | 1540 | the variables visible at that block will never go out of scope, |
1536 | and therefore they will not be closed. | 1541 | and therefore they will not be closed. |
1537 | (You should use finalizers to handle this case, | 1542 | Similarly, if a coroutine ends with an error, |
1538 | or else call @Lid{coroutine.kill} to close the variables.) | 1543 | it does not unwind its stack, |
1544 | so it does not close any variable. | ||
1545 | You should either use finalizers | ||
1546 | or call @Lid{coroutine.kill} to close the variables in these cases. | ||
1547 | However, note that if the coroutine was created | ||
1548 | through @Lid{coroutine.wrap}, | ||
1549 | then its corresponding function will close all variables | ||
1550 | in case of errors. | ||
1539 | 1551 | ||
1540 | } | 1552 | } |
1541 | 1553 | ||
@@ -6406,11 +6418,12 @@ or if it has stopped with an error. | |||
6406 | Creates a new coroutine, with body @id{f}; | 6418 | Creates a new coroutine, with body @id{f}; |
6407 | @id{f} must be a function. | 6419 | @id{f} must be a function. |
6408 | Returns a function that resumes the coroutine each time it is called. | 6420 | Returns a function that resumes the coroutine each time it is called. |
6409 | Any arguments passed to the function behave as the | 6421 | Any arguments passed to this function behave as the |
6410 | extra arguments to @id{resume}. | 6422 | extra arguments to @id{resume}. |
6411 | Returns the same values returned by @id{resume}, | 6423 | The function returns the same values returned by @id{resume}, |
6412 | except the first boolean. | 6424 | except the first boolean. |
6413 | In case of error, propagates the error. | 6425 | In case of error, |
6426 | the function kills the coroutine and propagates the error. | ||
6414 | 6427 | ||
6415 | } | 6428 | } |
6416 | 6429 | ||
@@ -6668,6 +6681,10 @@ the file path where the module was found, | |||
6668 | as returned by @Lid{package.searchpath}. | 6681 | as returned by @Lid{package.searchpath}. |
6669 | The first searcher always returns the string @St{:preload:}. | 6682 | The first searcher always returns the string @St{:preload:}. |
6670 | 6683 | ||
6684 | Searchers should raise no errors and have no side effects in Lua. | ||
6685 | (They may have side effects in C, | ||
6686 | for instance by linking the application with a library.) | ||
6687 | |||
6671 | } | 6688 | } |
6672 | 6689 | ||
6673 | @LibEntry{package.searchpath (name, path [, sep [, rep]])| | 6690 | @LibEntry{package.searchpath (name, path [, sep [, rep]])| |