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-github-7c8146d556714508224dc3f3a68677c18ece00b7.tar.gz
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.
You can set garbage-collector metamethods for tables
and, using the @N{C API},
for full userdata @see{metatable}.
-These metamethods are also called @def{finalizers}.
+These metamethods, called @def{finalizers},
+are called when the garbage collector detects that the
+corresponding table or userdata is unreachable.
Finalizers allow you to coordinate Lua's garbage collection
with external resource management
(such as closing files, network or database connections,
@@ -720,6 +722,10 @@ Lua calls the finalizers of all objects marked for finalization,
following the reverse order that they were marked.
If any finalizer marks objects for collection during that phase,
these marks have no effect.
+If any finalizer raises an error during that phase,
+its execution is interrupted but the error is ignored.
+
+Finalizers cannot yield.
}
@@ -5911,17 +5917,21 @@ If there are no syntactic errors,
returns the compiled chunk as a function;
otherwise, returns @nil plus the error message.
-If the resulting function has upvalues,
-the first upvalue is set to the value of @id{env},
-if that parameter is given,
-or to the value of the @x{global environment}.
-Other upvalues are initialized with @nil.
-(When you load a main chunk,
+When you load a main chunk,
the resulting function will always have exactly one upvalue,
the @id{_ENV} variable @see{globalenv}.
However,
when you load a binary chunk created from a function @seeF{string.dump},
-the resulting function can have an arbitrary number of upvalues.)
+the resulting function can have an arbitrary number of upvalues,
+and there is no guarantee that its first upvalue will be
+the @id{_ENV} variable.
+(A non-main function may not even have an @id{_ENV} upvalue.)
+
+Regardless, if the resulting function has any upvalues,
+its first upvalue is set to the value of @id{env},
+if that parameter is given,
+or to the value of the @x{global environment}.
+Other upvalues are initialized with @nil.
All upvalues are fresh, that is,
they are not shared with any other function.