summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-22 15:02:09 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-22 15:02:09 -0300
commit7c8146d556714508224dc3f3a68677c18ece00b7 (patch)
tree94e05e63ae49178af8de42999bf3587ed84881b1 /manual
parentc90176f96924ee7d207501b32f216925773d3bdb (diff)
downloadlua-7c8146d556714508224dc3f3a68677c18ece00b7.tar.gz
lua-7c8146d556714508224dc3f3a68677c18ece00b7.tar.bz2
lua-7c8146d556714508224dc3f3a68677c18ece00b7.zip
Small improvements in the manual
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of26
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.
664You can set garbage-collector metamethods for tables 664You can set garbage-collector metamethods for tables
665and, using the @N{C API}, 665and, using the @N{C API},
666for full userdata @see{metatable}. 666for full userdata @see{metatable}.
667These metamethods are also called @def{finalizers}. 667These metamethods, called @def{finalizers},
668are called when the garbage collector detects that the
669corresponding table or userdata is unreachable.
668Finalizers allow you to coordinate Lua's garbage collection 670Finalizers allow you to coordinate Lua's garbage collection
669with external resource management 671with 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,
720following the reverse order that they were marked. 722following the reverse order that they were marked.
721If any finalizer marks objects for collection during that phase, 723If any finalizer marks objects for collection during that phase,
722these marks have no effect. 724these marks have no effect.
725If any finalizer raises an error during that phase,
726its execution is interrupted but the error is ignored.
727
728Finalizers cannot yield.
723 729
724} 730}
725 731
@@ -5911,17 +5917,21 @@ If there are no syntactic errors,
5911returns the compiled chunk as a function; 5917returns the compiled chunk as a function;
5912otherwise, returns @nil plus the error message. 5918otherwise, returns @nil plus the error message.
5913 5919
5914If the resulting function has upvalues, 5920When you load a main chunk,
5915the first upvalue is set to the value of @id{env},
5916if that parameter is given,
5917or to the value of the @x{global environment}.
5918Other upvalues are initialized with @nil.
5919(When you load a main chunk,
5920the resulting function will always have exactly one upvalue, 5921the resulting function will always have exactly one upvalue,
5921the @id{_ENV} variable @see{globalenv}. 5922the @id{_ENV} variable @see{globalenv}.
5922However, 5923However,
5923when you load a binary chunk created from a function @seeF{string.dump}, 5924when you load a binary chunk created from a function @seeF{string.dump},
5924the resulting function can have an arbitrary number of upvalues.) 5925the resulting function can have an arbitrary number of upvalues,
5926and there is no guarantee that its first upvalue will be
5927the @id{_ENV} variable.
5928(A non-main function may not even have an @id{_ENV} upvalue.)
5929
5930Regardless, if the resulting function has any upvalues,
5931its first upvalue is set to the value of @id{env},
5932if that parameter is given,
5933or to the value of the @x{global environment}.
5934Other upvalues are initialized with @nil.
5925All upvalues are fresh, that is, 5935All upvalues are fresh, that is,
5926they are not shared with any other function. 5936they are not shared with any other function.
5927 5937