Skip to content

Commit 4148865

Browse files
committedJun 1, 2022
update
1 parent 821a0ec commit 4148865

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed
 

‎doc/en-us/54/manual.html

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1>
2020
<p>
2121
<small>
2222
<a href="http://www.lua.org/copyright.html">Copyright</a>
23-
&copy; 2021 Lua.org, PUC-Rio. All rights reserved.
23+
&copy; 2022 Lua.org, PUC-Rio. All rights reserved.
2424
</small>
2525
<hr>
2626

@@ -953,11 +953,8 @@ <h3>2.5.3 &ndash; <a name="2.5.3">Garbage-Collection Metamethods</a></h3>
953953

954954

955955
<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,
961958
it is good practice to restrict each finalizer
962959
to the minimum necessary to properly release
963960
its associated resource.
@@ -2418,16 +2415,21 @@ <h3>3.4.7 &ndash; <a name="3.4.7">The Length Operator</a></h3>
24182415
<p>
24192416
The length operator applied on a table
24202417
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
24222419
that satisfies the following condition:
24232420

24242421
<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)
24262424
</pre><p>
24272425
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.
24312433

24322434

24332435
<p>
@@ -2438,12 +2440,9 @@ <h3>3.4.7 &ndash; <a name="3.4.7">The Length Operator</a></h3>
24382440
and therefore it is not a sequence.
24392441
(The <b>nil</b> at index 4 is called a <em>hole</em>.)
24402442
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),
24432444
so it is not a sequence, too.
24442445
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.
24472446

24482447

24492448
<p>
@@ -2461,7 +2460,7 @@ <h3>3.4.7 &ndash; <a name="3.4.7">The Length Operator</a></h3>
24612460
<p>
24622461
The computation of the length of a table
24632462
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.
24652464

24662465

24672466
<p>
@@ -3064,7 +3063,7 @@ <h3>4.1.3 &ndash; <a name="4.1.3">Pointers to strings</a></h3>
30643063
Lua's garbage collection can free or move internal memory
30653064
and then invalidate pointers to internal strings.
30663065
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
30683067
is valid while the string value at that index is not removed from the stack.
30693068
(It can be moved to another index, though.)
30703069
When the index is a pseudo-index (referring to an upvalue),
@@ -3981,6 +3980,10 @@ <h2>4.6 &ndash; <a name="4.6">Functions and Types</a></h2>
39813980
see <a href="#pdf-collectgarbage"><code>collectgarbage</code></a>.
39823981

39833982

3983+
<p>
3984+
This function should not be called by a finalizer.
3985+
3986+
39843987

39853988

39863989

@@ -4974,6 +4977,7 @@ <h2>4.6 &ndash; <a name="4.6">Functions and Types</a></h2>
49744977
<p>
49754978
Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw access
49764979
(i.e., without metamethods).
4980+
The value at <code>index</code> must be a table.
49774981

49784982

49794983

@@ -5040,6 +5044,7 @@ <h2>4.6 &ndash; <a name="4.6">Functions and Types</a></h2>
50405044
<p>
50415045
Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw assignment
50425046
(i.e., without metamethods).
5047+
The value at <code>index</code> must be a table.
50435048

50445049

50455050

@@ -6762,7 +6767,7 @@ <h2>5.1 &ndash; <a name="5.1">Functions and Types</a></h2>
67626767
<pre>void luaL_buffsub (luaL_Buffer *B, int n);</pre>
67636768

67646769
<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>
67666771
(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
67676772
The buffer must have at least that many bytes.
67686773

@@ -7928,6 +7933,10 @@ <h2>6.1 &ndash; <a name="6.1">Basic Functions</a></h2>
79287933
and some of these options.
79297934

79307935

7936+
<p>
7937+
This function should not be called by a finalizer.
7938+
7939+
79317940

79327941

79337942
<p>
@@ -7945,7 +7954,7 @@ <h2>6.1 &ndash; <a name="6.1">Basic Functions</a></h2>
79457954

79467955
<p>
79477956
<hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
7948-
Raises an error (see <a href="#2.3">&sect;2.3</a>) with @{message} as the error object.
7957+
Raises an error (see <a href="#2.3">&sect;2.3</a>) with <code>message</code> as the error object.
79497958
This function never returns.
79507959

79517960

@@ -9296,7 +9305,7 @@ <h2>6.4 &ndash; <a name="6.4">String Manipulation</a></h2>
92969305

92979306

92989307
<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>
93009309
with the given format.
93019310
The format string cannot have the variable-length options
93029311
'<code>s</code>' or '<code>z</code>' (see <a href="#6.4.2">&sect;6.4.2</a>).

0 commit comments

Comments
 (0)
Please sign in to comment.