1919
2020< P >
2121< SMALL >
22- Copyright © 2020–2021 Lua.org, PUC-Rio.
22+ Copyright © 2020–2022 Lua.org, PUC-Rio.
2323Freely available under the terms of the
2424< a href ="http://www.lua.org/license.html "> Lua license</ a > .
2525</ SMALL >
@@ -961,11 +961,8 @@ <h3>2.5.3 – <a name="2.5.3">Garbage-Collection Metamethods</a></h3>
961961
962962
963963< p >
964- Finalizers cannot yield.
965- Except for that, they can do anything,
966- such as raise errors, create new objects,
967- or even run the garbage collector.
968- However, because they can run in unpredictable times,
964+ Finalizers cannot yield nor run the garbage collector.
965+ Because they can run in unpredictable times,
969966it is good practice to restrict each finalizer
970967to the minimum necessary to properly release
971968its associated resource.
@@ -1636,8 +1633,10 @@ <h3>3.3.3 – <a name="3.3.3">Assignment</a></h3>
16361633
16371634
16381635< p >
1639- The assignment statement first evaluates all its expressions
1640- and only then the assignments are performed.
1636+ If a variable is both assigned and read
1637+ inside a multiple assignment,
1638+ Lua ensures all reads get the value of the variable
1639+ before the assignment.
16411640Thus the code
16421641
16431642< pre >
@@ -1661,6 +1660,14 @@ <h3>3.3.3 – <a name="3.3.3">Assignment</a></h3>
16611660cyclically permutes the values of < code > x</ code > , < code > y</ code > , and < code > z</ code > .
16621661
16631662
1663+ < p >
1664+ Note that this guarantee covers only accesses
1665+ syntactically inside the assignment statement.
1666+ If a function or a metamethod called during the assignment
1667+ changes the value of a variable,
1668+ Lua gives no guarantees about the order of that access.
1669+
1670+
16641671< p >
16651672An assignment to a global name < code > x = val</ code >
16661673is equivalent to the assignment
@@ -2416,16 +2423,21 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
24162423< p >
24172424The length operator applied on a table
24182425returns a border in that table.
2419- A < em > border</ em > in a table < code > t</ code > is any natural number
2426+ A < em > border</ em > in a table < code > t</ code > is any non-negative integer
24202427that satisfies the following condition:
24212428
24222429< pre >
2423- (border == 0 or t[border] ~= nil) and t[border + 1] == nil
2430+ (border == 0 or t[border] ~= nil) and
2431+ (t[border + 1] == nil or border == math.maxinteger)
24242432</ pre > < p >
24252433In words,
2426- a border is any (natural) index present in the table
2427- that is followed by an absent index
2428- (or zero, when index 1 is absent).
2434+ a border is any positive integer index present in the table
2435+ that is followed by an absent index,
2436+ plus two limit cases:
2437+ zero, when index 1 is absent;
2438+ and the maximum value for an integer, when that index is present.
2439+ Note that keys that are not positive integers
2440+ do not interfere with borders.
24292441
24302442
24312443< p >
@@ -2436,12 +2448,9 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
24362448and therefore it is not a sequence.
24372449(The < b > nil</ b > at index 4 is called a < em > hole</ em > .)
24382450The table < code > {nil, 20, 30, nil, nil, 60, nil}</ code >
2439- has three borders (0, 3, and 6) and three holes
2440- (at indices 1, 4, and 5),
2451+ has three borders (0, 3, and 6),
24412452so it is not a sequence, too.
24422453The table < code > {}</ code > is a sequence with border 0.
2443- Note that non-natural keys do not interfere
2444- with whether a table is a sequence.
24452454
24462455
24472456< p >
@@ -2459,7 +2468,7 @@ <h3>3.4.7 – <a name="3.4.7">The Length Operator</a></h3>
24592468< p >
24602469The computation of the length of a table
24612470has a guaranteed worst time of < em > O(log n)</ em > ,
2462- where < em > n</ em > is the largest natural key in the table.
2471+ where < em > n</ em > is the largest integer key in the table.
24632472
24642473
24652474< p >
@@ -3979,6 +3988,10 @@ <h2>4.6 – <a name="4.6">Functions and Types</a></h2>
39793988see < a href ="#pdf-collectgarbage "> < code > collectgarbage</ code > </ a > .
39803989
39813990
3991+ < p >
3992+ This function should not be called by a finalizer.
3993+
3994+
39823995
39833996
39843997
@@ -5933,7 +5946,10 @@ <h2>4.7 – <a name="4.7">The Debug Interface</a></h2>
59335946< a href ="#lua_getstack "> < code > lua_getstack</ code > </ a > fills only the private part
59345947of this structure, for later use.
59355948To fill the other fields of < a href ="#lua_Debug "> < code > lua_Debug</ code > </ a > with useful information,
5936- you must call < a href ="#lua_getinfo "> < code > lua_getinfo</ code > </ a > .
5949+ you must call < a href ="#lua_getinfo "> < code > lua_getinfo</ code > </ a > with an appropriate parameter.
5950+ (Specifically, to get a field,
5951+ you must add the letter between parentheses in the field's comment
5952+ to the parameter < code > what</ code > of < a href ="#lua_getinfo "> < code > lua_getinfo</ code > </ a > .)
59375953
59385954
59395955< p >
@@ -6110,47 +6126,46 @@ <h2>4.7 – <a name="4.7">The Debug Interface</a></h2>
61106126< p >
61116127Each character in the string < code > what</ code >
61126128selects some fields of the structure < code > ar</ code > to be filled or
6113- a value to be pushed on the stack:
6129+ a value to be pushed on the stack.
6130+ (These characters are also documented in the declaration of
6131+ the structure < a href ="#lua_Debug "> < code > lua_Debug</ code > </ a > ,
6132+ between parentheses in the comments following each field.)
61146133
61156134< ul >
61166135
6117- < li > < b > '< code > n</ code > ': </ b > fills in the field < code > name</ code > and < code > namewhat</ code > ;
6136+ < li > < b > '< code > f</ code > ': </ b >
6137+ pushes onto the stack the function that is
6138+ running at the given level;
6139+ </ li >
6140+
6141+ < li > < b > '< code > l</ code > ': </ b > fills in the field < code > currentline</ code > ;
6142+ </ li >
6143+
6144+ < li > < b > '< code > n</ code > ': </ b > fills in the fields < code > name</ code > and < code > namewhat</ code > ;
6145+ </ li >
6146+
6147+ < li > < b > '< code > r</ code > ': </ b > fills in the fields < code > ftransfer</ code > and < code > ntransfer</ code > ;
61186148</ li >
61196149
61206150< li > < b > '< code > S</ code > ': </ b >
61216151fills in the fields < code > source</ code > , < code > short_src</ code > ,
61226152< code > linedefined</ code > , < code > lastlinedefined</ code > , and < code > what</ code > ;
61236153</ li >
61246154
6125- < li > < b > '< code > l</ code > ': </ b > fills in the field < code > currentline</ code > ;
6126- </ li >
6127-
61286155< li > < b > '< code > t</ code > ': </ b > fills in the field < code > istailcall</ code > ;
61296156</ li >
61306157
61316158< li > < b > '< code > u</ code > ': </ b > fills in the fields
61326159< code > nups</ code > , < code > nparams</ code > , and < code > isvararg</ code > ;
61336160</ li >
61346161
6135- < li > < b > '< code > f</ code > ': </ b >
6136- pushes onto the stack the function that is
6137- running at the given level;
6138- </ li >
6139-
61406162< li > < b > '< code > L</ code > ': </ b >
6141- pushes onto the stack a table whose indices are the
6142- numbers of the lines that are valid on the function.
6143- (A < em > valid line</ em > is a line with some associated code,
6144- that is, a line where you can put a break point.
6145- Non-valid lines include empty lines and comments.)
6146-
6147-
6148- < p >
6163+ pushes onto the stack a table whose indices are
6164+ the lines on the function with some associated code,
6165+ that is, the lines where you can put a break point.
6166+ (Lines with no code include empty lines and comments.)
61496167If this option is given together with option '< code > f</ code > ',
61506168its table is pushed after the function.
6151-
6152-
6153- < p >
61546169This is the only option that can raise a memory error.
61556170</ li >
61566171
@@ -6508,7 +6523,7 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
65086523
65096524
65106525< hr > < h3 > < a name ="luaL_addgsub "> < code > luaL_addgsub</ code > </ a > </ h3 > < p >
6511- < span class ="apii "> [-0 , +0 , < em > m</ em > ]</ span >
6526+ < span class ="apii "> [-? , +? , < em > m</ em > ]</ span >
65126527< pre > const void luaL_addgsub (luaL_Buffer *B, const char *s,
65136528 const char *p, const char *r);</ pre >
65146529
@@ -6562,7 +6577,7 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
65626577
65636578
65646579< hr > < h3 > < a name ="luaL_addvalue "> < code > luaL_addvalue</ code > </ a > </ h3 > < p >
6565- < span class ="apii "> [-1 , +?, < em > m</ em > ]</ span >
6580+ < span class ="apii "> [-? , +?, < em > m</ em > ]</ span >
65666581< pre > void luaL_addvalue (luaL_Buffer *B);</ pre >
65676582
65686583< p >
@@ -6716,7 +6731,7 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
67166731
67176732
67186733< hr > < h3 > < a name ="luaL_buffinit "> < code > luaL_buffinit</ code > </ a > </ h3 > < p >
6719- < span class ="apii "> [-0, +0 , –]</ span >
6734+ < span class ="apii "> [-0, +? , –]</ span >
67206735< pre > void luaL_buffinit (lua_State *L, luaL_Buffer *B);</ pre >
67216736
67226737< p >
@@ -6754,7 +6769,7 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
67546769
67556770
67566771< hr > < h3 > < a name ="luaL_buffsub "> < code > luaL_buffsub</ code > </ a > </ h3 > < p >
6757- < span class ="apii "> [-0 , +0 , –]</ span >
6772+ < span class ="apii "> [-? , +? , –]</ span >
67586773< pre > void luaL_buffsub (luaL_Buffer *B, int n);</ pre >
67596774
67606775< p >
@@ -7557,6 +7572,11 @@ <h2>5.1 – <a name="5.1">Functions and Types</a></h2>
75577572These values are popped from the stack after the registration.
75587573
75597574
7575+ < p >
7576+ A function with a < code > NULL</ code > value represents a placeholder,
7577+ which is filled with < b > false</ b > .
7578+
7579+
75607580
75617581
75627582
@@ -7919,6 +7939,10 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
79197939and some of these options.
79207940
79217941
7942+ < p >
7943+ This function should not be called by a finalizer.
7944+
7945+
79227946
79237947
79247948< p >
@@ -7936,7 +7960,7 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
79367960
79377961< p >
79387962< hr > < h3 > < a name ="pdf-error "> < code > error (message [, level])</ code > </ a > </ h3 >
7939- Raises an error (see < a href ="#2.3 "> §2.3</ a > ) with @{ message} as the error object.
7963+ Raises an error (see < a href ="#2.3 "> §2.3</ a > ) with < code > message</ code > as the error object.
79407964This function never returns.
79417965
79427966
@@ -8111,9 +8135,8 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
81118135
81128136
81138137< p >
8114- The behavior of < code > next</ code > is undefined if,
8115- during the traversal,
8116- you assign any value to a non-existent field in the table.
8138+ You should not assign any value to a non-existent field in a table
8139+ during its traversal.
81178140You may however modify existing fields.
81188141In particular, you may set existing fields to nil.
81198142
@@ -8159,7 +8182,7 @@ <h2>6.1 – <a name="6.1">Basic Functions</a></h2>
81598182instead, < code > pcall</ code > catches the error
81608183and returns a status code.
81618184Its first result is the status code (a boolean),
8162- which is true if the call succeeds without errors.
8185+ which is < b > true</ b > if the call succeeds without errors.
81638186In such case, < code > pcall</ code > also returns all results from the call,
81648187after this first result.
81658188In case of any error, < code > pcall</ code > returns < b > false</ b > plus the error object.
@@ -8439,7 +8462,7 @@ <h2>6.2 – <a name="6.2">Coroutine Manipulation</a></h2>
84398462
84408463
84418464< p >
8442- Returns true when the coroutine < code > co</ code > can yield.
8465+ Returns < b > true</ b > when the coroutine < code > co</ code > can yield.
84438466The default for < code > co</ code > is the running coroutine.
84448467
84458468
@@ -8483,7 +8506,7 @@ <h2>6.2 – <a name="6.2">Coroutine Manipulation</a></h2>
84838506
84848507< p >
84858508Returns the running coroutine plus a boolean,
8486- true when the running coroutine is the main one.
8509+ < b > true</ b > when the running coroutine is the main one.
84878510
84888511
84898512
@@ -9021,7 +9044,7 @@ <h2>6.4 – <a name="6.4">String Manipulation</a></h2>
90219044A third, optional numeric argument < code > init</ code > specifies
90229045where to start the search;
90239046its default value is 1 and can be negative.
9024- A value of < b > true</ b > as a fourth, optional argument < code > plain</ code >
9047+ A < b > true</ b > as a fourth, optional argument < code > plain</ code >
90259048turns off the pattern matching facilities,
90269049so the function does a plain "find substring" operation,
90279050with no characters in < code > pattern</ code > being considered magic.
@@ -9046,8 +9069,10 @@ <h2>6.4 – <a name="6.4">String Manipulation</a></h2>
90469069which must be a string.
90479070The format string follows the same rules as the ISO C function < code > sprintf</ code > .
90489071The only differences are that the conversion specifiers and modifiers
9049- < code > * </ code > , < code > h </ code > , < code > L </ code > , < code > l </ code > , and < code > n </ code > are not supported
9072+ < code > F </ code > , < code > n </ code > , < code > * </ code > , < code > h </ code > , < code > L </ code > , and < code > l </ code > are not supported
90509073and that there is an extra specifier, < code > q</ code > .
9074+ Both width and precision, when present,
9075+ are limited to two digits.
90519076
90529077
90539078< p >
@@ -9071,7 +9096,7 @@ <h2>6.4 – <a name="6.4">String Manipulation</a></h2>
90719096 "a string with \"quotes\" and \
90729097 new line"
90739098</ pre > < p >
9074- This specifier does not support modifiers (flags, width, length ).
9099+ This specifier does not support modifiers (flags, width, precision ).
90759100
90769101
90779102< p >
@@ -10362,7 +10387,7 @@ <h2>6.7 – <a name="6.7">Mathematical Functions</a></h2>
1036210387
1036310388< p >
1036410389Returns a boolean,
10365- true if and only if integer < code > m</ code > is below integer < code > n</ code > when
10390+ < b > true</ b > if and only if integer < code > m</ code > is below integer < code > n</ code > when
1036610391they are compared as unsigned integers.
1036710392
1036810393
@@ -11924,10 +11949,10 @@ <h1>9 – <a name="9">The Complete Syntax of Lua</a></h1>
1192411949
1192511950< P CLASS ="footer ">
1192611951Last update:
11927- Mon Mar 15 13:39:42 UTC 2021
11952+ Thu Jan 13 11:33:16 UTC 2022
1192811953</ P >
1192911954<!--
11930- Last change: revised for Lua 5.4.3
11955+ Last change: revised for Lua 5.4.4
1193111956-->
1193211957
1193311958</ body > </ html >
0 commit comments