20
20
< p >
21
21
< small >
22
22
< a href ="http://www.lua.org/copyright.html "> Copyright</ a >
23
- © 2021 Lua.org, PUC-Rio. All rights reserved.
23
+ © 2022 Lua.org, PUC-Rio. All rights reserved.
24
24
</ small >
25
25
< hr >
26
26
@@ -953,11 +953,8 @@ <h3>2.5.3 – <a name="2.5.3">Garbage-Collection Metamethods</a></h3>
953
953
954
954
955
955
< p >
956
- Finalizers cannot yield.
957
- Except for that, they can do anything,
958
- such as raise errors, create new objects,
959
- or even run the garbage collector.
960
- However, because they can run in unpredictable times,
956
+ Finalizers cannot yield nor run the garbage collector.
957
+ Because they can run in unpredictable times,
961
958
it is good practice to restrict each finalizer
962
959
to the minimum necessary to properly release
963
960
its associated resource.
@@ -2418,16 +2415,21 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
2418
2415
< p >
2419
2416
The length operator applied on a table
2420
2417
returns a border in that table.
2421
- A < em > border</ em > in a table < code > t</ code > is any natural number
2418
+ A < em > border</ em > in a table < code > t</ code > is any non-negative integer
2422
2419
that satisfies the following condition:
2423
2420
2424
2421
< pre >
2425
- (border == 0 or t[border] ~= nil) and t[border + 1] == nil
2422
+ (border == 0 or t[border] ~= nil) and
2423
+ (t[border + 1] == nil or border == math.maxinteger)
2426
2424
</ pre > < p >
2427
2425
In words,
2428
- a border is any (natural) index present in the table
2429
- that is followed by an absent index
2430
- (or zero, when index 1 is absent).
2426
+ a border is any positive integer index present in the table
2427
+ that is followed by an absent index,
2428
+ plus two limit cases:
2429
+ zero, when index 1 is absent;
2430
+ and the maximum value for an integer, when that index is present.
2431
+ Note that keys that are not positive integers
2432
+ do not interfere with borders.
2431
2433
2432
2434
2433
2435
< p >
@@ -2438,12 +2440,9 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
2438
2440
and therefore it is not a sequence.
2439
2441
(The < b > nil</ b > at index 4 is called a < em > hole</ em > .)
2440
2442
The table < code > {nil, 20, 30, nil, nil, 60, nil}</ code >
2441
- has three borders (0, 3, and 6) and three holes
2442
- (at indices 1, 4, and 5),
2443
+ has three borders (0, 3, and 6),
2443
2444
so it is not a sequence, too.
2444
2445
The table < code > {}</ code > is a sequence with border 0.
2445
- Note that non-natural keys do not interfere
2446
- with whether a table is a sequence.
2447
2446
2448
2447
2449
2448
< p >
@@ -2461,7 +2460,7 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
2461
2460
< p >
2462
2461
The computation of the length of a table
2463
2462
has a guaranteed worst time of < em > O(log n)</ em > ,
2464
- where < em > n</ em > is the largest natural key in the table.
2463
+ where < em > n</ em > is the largest integer key in the table.
2465
2464
2466
2465
2467
2466
< p >
@@ -3064,7 +3063,7 @@ <h3>4.1.3 – <a name="4.1.3">Pointers to strings</a></h3>
3064
3063
Lua's garbage collection can free or move internal memory
3065
3064
and then invalidate pointers to internal strings.
3066
3065
To allow a safe use of these pointers,
3067
- The API guarantees that any pointer to a string in a stack index
3066
+ the API guarantees that any pointer to a string in a stack index
3068
3067
is valid while the string value at that index is not removed from the stack.
3069
3068
(It can be moved to another index, though.)
3070
3069
When the index is a pseudo-index (referring to an upvalue),
@@ -3981,6 +3980,10 @@ <h2>4.6 – <a name="4.6">Functions and Types</a></h2>
3981
3980
see < a href ="#pdf-collectgarbage "> < code > collectgarbage</ code > </ a > .
3982
3981
3983
3982
3983
+ < p >
3984
+ This function should not be called by a finalizer.
3985
+
3986
+
3984
3987
3985
3988
3986
3989
@@ -4974,6 +4977,7 @@ <h2>4.6 – <a name="4.6">Functions and Types</a></h2>
4974
4977
< p >
4975
4978
Similar to < a href ="#lua_gettable "> < code > lua_gettable</ code > </ a > , but does a raw access
4976
4979
(i.e., without metamethods).
4980
+ The value at < code > index</ code > must be a table.
4977
4981
4978
4982
4979
4983
@@ -5040,6 +5044,7 @@ <h2>4.6 – <a name="4.6">Functions and Types</a></h2>
5040
5044
< p >
5041
5045
Similar to < a href ="#lua_settable "> < code > lua_settable</ code > </ a > , but does a raw assignment
5042
5046
(i.e., without metamethods).
5047
+ The value at < code > index</ code > must be a table.
5043
5048
5044
5049
5045
5050
@@ -6762,7 +6767,7 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
6762
6767
< pre > void luaL_buffsub (luaL_Buffer *B, int n);</ pre >
6763
6768
6764
6769
< p >
6765
- Removes < code > n</ code > bytes from the the buffer < code > B</ code >
6770
+ Removes < code > n</ code > bytes from the buffer < code > B</ code >
6766
6771
(see < a href ="#luaL_Buffer "> < code > luaL_Buffer</ code > </ a > ).
6767
6772
The buffer must have at least that many bytes.
6768
6773
@@ -7928,6 +7933,10 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
7928
7933
and some of these options.
7929
7934
7930
7935
7936
+ < p >
7937
+ This function should not be called by a finalizer.
7938
+
7939
+
7931
7940
7932
7941
7933
7942
< p >
@@ -7945,7 +7954,7 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
7945
7954
7946
7955
< p >
7947
7956
< hr > < h3 > < a name ="pdf-error "> < code > error (message [, level])</ code > </ a > </ h3 >
7948
- Raises an error (see < a href ="#2.3 "> §2.3</ a > ) with @{ message} as the error object.
7957
+ Raises an error (see < a href ="#2.3 "> §2.3</ a > ) with < code > message</ code > as the error object.
7949
7958
This function never returns.
7950
7959
7951
7960
@@ -9296,7 +9305,7 @@ <h2>6.4 – <a name="6.4">String Manipulation</a></h2>
9296
9305
9297
9306
9298
9307
< p >
9299
- Returns the size of a string resulting from < a href ="#pdf-string.pack "> < code > string.pack</ code > </ a >
9308
+ Returns the length of a string resulting from < a href ="#pdf-string.pack "> < code > string.pack</ code > </ a >
9300
9309
with the given format.
9301
9310
The format string cannot have the variable-length options
9302
9311
'< code > s</ code > ' or '< code > z</ code > ' (see < a href ="#6.4.2 "> §6.4.2</ a > ).
0 commit comments