diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-22 15:02:09 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-22 15:02:09 -0300 |
| commit | 7c8146d556714508224dc3f3a68677c18ece00b7 (patch) | |
| tree | 94e05e63ae49178af8de42999bf3587ed84881b1 | |
| parent | c90176f96924ee7d207501b32f216925773d3bdb (diff) | |
| download | lua-7c8146d556714508224dc3f3a68677c18ece00b7.tar.gz lua-7c8146d556714508224dc3f3a68677c18ece00b7.tar.bz2 lua-7c8146d556714508224dc3f3a68677c18ece00b7.zip | |
Small improvements in the manual
| -rw-r--r-- | manual/manual.of | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/manual/manual.of b/manual/manual.of index 47a551bf..d8bac5da 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -664,7 +664,9 @@ The default value is 20; the maximum value is 200. | |||
| 664 | You can set garbage-collector metamethods for tables | 664 | You can set garbage-collector metamethods for tables |
| 665 | and, using the @N{C API}, | 665 | and, using the @N{C API}, |
| 666 | for full userdata @see{metatable}. | 666 | for full userdata @see{metatable}. |
| 667 | These metamethods are also called @def{finalizers}. | 667 | These metamethods, called @def{finalizers}, |
| 668 | are called when the garbage collector detects that the | ||
| 669 | corresponding table or userdata is unreachable. | ||
| 668 | Finalizers allow you to coordinate Lua's garbage collection | 670 | Finalizers allow you to coordinate Lua's garbage collection |
| 669 | with external resource management | 671 | with external resource management |
| 670 | (such as closing files, network or database connections, | 672 | (such as closing files, network or database connections, |
| @@ -720,6 +722,10 @@ Lua calls the finalizers of all objects marked for finalization, | |||
| 720 | following the reverse order that they were marked. | 722 | following the reverse order that they were marked. |
| 721 | If any finalizer marks objects for collection during that phase, | 723 | If any finalizer marks objects for collection during that phase, |
| 722 | these marks have no effect. | 724 | these marks have no effect. |
| 725 | If any finalizer raises an error during that phase, | ||
| 726 | its execution is interrupted but the error is ignored. | ||
| 727 | |||
| 728 | Finalizers cannot yield. | ||
| 723 | 729 | ||
| 724 | } | 730 | } |
| 725 | 731 | ||
| @@ -5911,17 +5917,21 @@ If there are no syntactic errors, | |||
| 5911 | returns the compiled chunk as a function; | 5917 | returns the compiled chunk as a function; |
| 5912 | otherwise, returns @nil plus the error message. | 5918 | otherwise, returns @nil plus the error message. |
| 5913 | 5919 | ||
| 5914 | If the resulting function has upvalues, | 5920 | When you load a main chunk, |
| 5915 | the first upvalue is set to the value of @id{env}, | ||
| 5916 | if that parameter is given, | ||
| 5917 | or to the value of the @x{global environment}. | ||
| 5918 | Other upvalues are initialized with @nil. | ||
| 5919 | (When you load a main chunk, | ||
| 5920 | the resulting function will always have exactly one upvalue, | 5921 | the resulting function will always have exactly one upvalue, |
| 5921 | the @id{_ENV} variable @see{globalenv}. | 5922 | the @id{_ENV} variable @see{globalenv}. |
| 5922 | However, | 5923 | However, |
| 5923 | when you load a binary chunk created from a function @seeF{string.dump}, | 5924 | when you load a binary chunk created from a function @seeF{string.dump}, |
| 5924 | the resulting function can have an arbitrary number of upvalues.) | 5925 | the resulting function can have an arbitrary number of upvalues, |
| 5926 | and there is no guarantee that its first upvalue will be | ||
| 5927 | the @id{_ENV} variable. | ||
| 5928 | (A non-main function may not even have an @id{_ENV} upvalue.) | ||
| 5929 | |||
| 5930 | Regardless, if the resulting function has any upvalues, | ||
| 5931 | its first upvalue is set to the value of @id{env}, | ||
| 5932 | if that parameter is given, | ||
| 5933 | or to the value of the @x{global environment}. | ||
| 5934 | Other upvalues are initialized with @nil. | ||
| 5925 | All upvalues are fresh, that is, | 5935 | All upvalues are fresh, that is, |
| 5926 | they are not shared with any other function. | 5936 | they are not shared with any other function. |
| 5927 | 5937 | ||
