Lines Matching +full:tp +full:- +full:sensitive +full:- +full:adjust
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
7 <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
22 Copyright © 2020–2023 Lua.org, PUC-Rio.
35 <!-- ====================================================================== -->
38 <!-- $Id: manual.of $ -->
48 object-oriented programming, functional programming,
49 data-driven programming, and data description.
56 runs by interpreting bytecode with a register-based
73 and as a powerful but lightweight and efficient stand-alone language.
80 (Frequently, this host is the stand-alone <code>lua</code> program.)
129 All values in Lua are first-class values.
155 integer numbers and real (floating-point) numbers,
157 Standard Lua uses 64-bit integers and double-precision (64-bit) floats,
159 uses 32-bit integers and/or single-precision (32-bit) floats.
169 according to the usual rules of two-complement arithmetic.
188 Lua is 8-bit clean:
189 strings can contain any 8-bit value,
191 Lua is also encoding-agnostic;
225 Lua threads are not related to operating-system threads.
234 (<em>Not a Number</em> is a special floating-point value
245 Tables are the sole data-structuring mechanism in Lua;
259 because functions are first-class values,
291 The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
292 of a given value (see <a href="#pdf-type"><code>type</code></a>).
328 In Lua, the global variable <a href="#pdf-_G"><code>_G</code></a> is initialized with this same val…
329 (<a href="#pdf-_G"><code>_G</code></a> is never used internally,
336 is the global environment (see <a href="#pdf-load"><code>load</code></a>).
342 You can use <a href="#pdf-load"><code>load</code></a> (or <a href="#pdf-loadfile"><code>loadfile</c…
361 <a href="#pdf-error"><code>error</code></a> function.
368 using <a href="#pdf-pcall"><code>pcall</code></a> (or <a href="#pdf-xpcall"><code>xpcall</code></a>…
369 The function <a href="#pdf-pcall"><code>pcall</code></a> calls a given function in <em>protected mo…
403 When you use <a href="#pdf-xpcall"><code>xpcall</code></a> (or <a href="#lua_pcall"><code>lua_pcall…
417 It is not called for memory-allocation errors
422 Lua also offers a system of <em>warnings</em> (see <a href="#pdf-warn"><code>warn</code></a>).
441 For instance, when a non-numeric value is the operand of an addition,
462 using the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.
463 Lua queries metamethods in metatables using a raw access (see <a href="#pdf-rawget"><code>rawget</c…
468 using the <a href="#pdf-setmetatable"><code>setmetatable</code></a> function.
510 the subtraction (<code>-</code>) operation.
535 the negation (unary <code>-</code>) operation.
667 the metamethod itself can call <a href="#pdf-rawset"><code>rawset</code></a>
673 This event happens when Lua tries to call a non-function value
695 may be used by <a href="#pdf-tostring"><code>tostring</code></a> and in error messages.)
713 (e.g., <a href="#pdf-tostring"><code>tostring</code></a>)
775 Keep in mind that the GC behavior is non-portable
777 therefore, optimal settings are also non-portable.
783 or <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> in Lua.
795 each GC cycle performs a mark-and-sweep collection in small steps
798 the collector uses three numbers to control its garbage-collection cycles:
799 the <em>garbage-collector pause</em>,
800 the <em>garbage-collector step multiplier</em>,
801 and the <em>garbage-collector step size</em>.
805 The garbage-collector pause
818 The garbage-collector step multiplier
833 The garbage-collector step size controls the
840 A large value (e.g., 60) makes the collector a stop-the-world
841 (non-incremental) collector.
856 the collector does a stop-the-world <em>major</em> collection,
889 <h3>2.5.3 – <a name="2.5.3">Garbage-Collection Metamethods</a></h3>
892 You can set garbage-collector metamethods for tables
928 At the end of each garbage-collection cycle,
943 and the object memory is freed in the next garbage-collection cycle.
1072 You create a coroutine by calling <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
1081 You execute a coroutine by calling <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a…
1082 When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
1084 a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
1087 Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are pas…
1099 <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>true</b>,
1101 In case of errors, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>fal…
1109 A coroutine yields by calling <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
1111 the corresponding <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns immedia…
1115 In the case of a yield, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> also retu…
1116 plus any values passed to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
1119 with the call to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a> returning any extra
1120 arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
1124 Like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
1125 the <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function also creates a coroutine,
1129 go as extra arguments to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
1130 <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> returns all the values returned by <a…
1132 Unlike <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
1133 the function created by <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a>
1136 the function also closes the coroutine (see <a href="#pdf-coroutine.close"><code>coroutine.close</c…
1150 print("co-body", a, b)
1152 print("co-body", r)
1153 local r, s = coroutine.yield(a+b, a-b)
1154 print("co-body", r, s)
1166 co-body 1 10
1169 co-body r
1170 main true 11 -9
1171 co-body x y
1203 Non-terminals are shown like non-terminal,
1216 Lua is a free-form language.
1229 Arabic-Indic digits, and underscores,
1248 Lua is a case-sensitive language:
1254 one or more uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>).
1261 + - * / % ^ #
1271 and can contain the following C-like escape sequences:
1308 The UTF-8 encoding of a Unicode character
1315 (Lua uses the original UTF-8 specification here,
1337 Any kind of end-of-line sequence
1370 explicit escape sequences for the non-text characters.
1410 3.0 3.1416 314.16e-2 0.31416E1 34e1
1411 0x0.1E 0xA23p-4 0X1.921FB54442D18P+1
1415 A <em>comment</em> starts with a double hyphen (<code>--</code>)
1417 If the text immediately after <code>--</code> is not an opening long bracket,
1598 see the program <code>luac</code> and the function <a href="#pdf-string.dump"><code>string.dump</co…
1600 Lua automatically detects the file type and acts accordingly (see <a href="#pdf-load"><code>load</c…
1807 Beware of floating-point accuracy in this case.
1891 to-be-closed variable (see <a href="#3.3.8">§3.3.8</a>),
1907 To allow possible side-effects,
1944 and <code>close</code>, which declares a to-be-closed variable (see <a href="#3.3.8">§3.3.8</a…
1945 A list of variables can contain at most one to-be-closed variable.
1960 <h3>3.3.8 – <a name="3.3.8">To-be-closed Variables</a></h3>
1963 A to-be-closed variable behaves like a constant local variable,
1981 The value assigned to a to-be-closed variable
1984 (<b>nil</b> and <b>false</b> are ignored as to-be-closed values.)
1988 If several to-be-closed variables go out of scope at the same event,
2011 or call <a href="#pdf-coroutine.close"><code>coroutine.close</code></a> to close the variables.
2013 through <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a>,
2074 <li><b><code>-</code>: </b>subtraction</li>
2080 <li><b><code>-</code>: </b>unary minus</li>
2091 for floating-point arithmetic
2103 so that it works for non-integer exponents too.
2224 non-specified human-readable format.
2226 use the function <a href="#pdf-string.format"><code>string.format</code></a>.
2324 Both <b>and</b> and <b>or</b> use short-circuit evaluation;
2330 10 or 20 --> 10
2331 10 or error() --> 10
2332 nil or "a" --> "a"
2333 nil and 10 --> nil
2334 false and error() --> false
2335 false and nil --> false
2336 false or nil --> nil
2337 10 and 20 --> 20
2348 in a non-specified format (see <a href="#3.4.3">§3.4.3</a>).
2370 A <em>border</em> in a table <code>t</code> is any non-negative integer
2409 the memory addresses of its non-numeric keys.)
2439 + -
2441 unary operators (not # - ~)
2488 t[1] = "x" -- 1st exp
2489 t[2] = "y" -- 2nd exp
2490 t.x = 1 -- t["x"] = 1
2491 t[3] = f(x) -- 3rd exp
2493 t[4] = 45 -- 4th exp
2512 as a convenience for machine-generated code.
2568 scope of a to-be-closed variable is called a <em>tail call</em>.
2579 and it is outside the scope of any to-be-closed variable.
2586 return (f(x)) -- results adjusted to 1
2587 return 2 * f(x) -- result multiplied by 2
2588 return x, f(x) -- additional results
2589 f(x); return -- results discarded
2590 return x or f(x) -- results adjusted to 1
2678 A variadic function does not adjust its argument list;
2706 g(3) a=3, b=nil, ... --> (nothing)
2707 g(3, 4) a=3, b=4, ... --> (nothing)
2708 g(3, 4, 5, 8) a=3, b=4, ... --> 5 8
2709 g(5, r()) a=5, b=1, ... --> 2 3
2721 There is a system-dependent limit on the number of values
2789 the number of parameters in a call to a non-variadic function
2829 "the n-th result" and there is no such result,
2833 print(x, f()) -- prints x and all results from f().
2834 print(x, (f())) -- prints x and the first result from f().
2835 print(f(), x) -- prints the first result from f() and x.
2836 print(1 + f()) -- prints 1 added to the first result from f().
2837 local x = ... -- x gets the first vararg argument.
2838 x,y = ... -- x gets the first vararg argument,
2839 -- y gets the second vararg argument.
2840 x,y,z = w, f() -- x gets w, y gets the first result from f(),
2841 -- z gets the second result from f().
2842 x,y,z = f() -- x gets the first result from f(),
2843 -- y gets the second result from f(),
2844 -- z gets the third result from f().
2845 x,y,z = f(), g() -- x gets the first result from f(),
2846 -- y gets the first result from g(),
2847 -- z gets the second result from g().
2848 x,y,z = (f()) -- x gets the first result from f(), y and z get nil.
2849 return f() -- returns all results from f().
2850 return x, ... -- returns x and all received vararg arguments.
2851 return x,y,f() -- returns x, y, and all results from f().
2852 {f()} -- creates a list with all results from f().
2853 {...} -- creates a list with all vararg arguments.
2854 {f(), 5} -- creates a list with the first result from f() and 5.
2868 its declaration and lasts until the last non-void statement
2874 x = 10 -- global variable
2875 do -- new block
2876 local x = x -- new 'x', with value 10
2877 print(x) --> 10
2879 do -- another block
2880 local x = x+1 -- another 'x'
2881 print(x) --> 12
2883 print(x) --> 11
2885 print(x) --> 10 (the global one)
2935 are declared in the header file <a name="pdf-lua.h"><code>lua.h</code></a>.
2944 and so do not generate any hidden side-effects.
2952 with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a> defined.
3015 index -1 also represents the last element
3017 and index <em>-n</em> represents the first element.
3047 at least <a name="pdf-LUA_MINSTACK"><code>LUA_MINSTACK</code></a> extra elements;
3073 plus <em>pseudo-indices</em>,
3076 Pseudo-indices are used to access the registry (see <a href="#4.3">§4.3</a>)
3105 any non-valid index is treated as if it
3106 contains a value of a virtual type <a name="pdf-LUA_TNONE"><code>LUA_TNONE</code></a>,
3132 When the index is a pseudo-index (referring to an upvalue),
3171 its upvalues are located at specific pseudo-indices.
3172 These pseudo-indices are produced by the macro
3198 The registry table is always accessible at pseudo-index
3199 <a name="pdf-LUA_REGISTRYINDEX"><code>LUA_REGISTRYINDEX</code></a>.
3228 <li><b><a name="pdf-LUA_RIDX_MAINTHREAD"><code>LUA_RIDX_MAINTHREAD</code></a>: </b> At this index t…
3233 <li><b><a name="pdf-LUA_RIDX_GLOBALS"><code>LUA_RIDX_GLOBALS</code></a>: </b> At this index the reg…
3291 (e.g., a Lua-state argument to the function,
3316 <li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b> no errors.</li>
3318 <li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>: </b> a runtime error.</li>
3320 <li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
3325 <li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>: </b> error while running the message h…
3327 <li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>: </b> syntax error during precomp…
3329 <li><b><a name="pdf-LUA_YIELD"><code>LUA_YIELD</code></a>: </b> the thread (coroutine) yields.</li>
3331 <li><b><a name="pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a>: </b> a file-related error;
3449 except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after a y…
3450 (instead of <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>).
3452 the status is always <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when Lua calls the continu…
3458 with <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> as the status.
3486 <span class="apii">[-o, +p, <em>x</em>]</span>
3504 '<code>-</code>' means the function never raises any error;
3505 '<code>m</code>' means the function may raise only out-of-memory errors;
3514 <span class="apii">[-0, +0, –]</span>
3533 The type of the memory-allocation function used by Lua states.
3555 <a href="#pdf-LUA_TSTRING"><code>LUA_TSTRING</code></a>, <a href="#pdf-LUA_TTABLE"><code>LUA_TTABLE…
3556 <a href="#pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>, or <a href="#pdf-LUA_TTHREAD"><code>LU…
3604 <span class="apii">[-(2|1), +1, <em>e</em>]</span>
3622 <li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>: </b> performs addition (<code>+</code>)<…
3623 <li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>: </b> performs subtraction (<code>-</code…
3624 <li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>: </b> performs multiplication (<code>*</c…
3625 <li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>: </b> performs float division (<code>/</c…
3626 <li><b><a name="pdf-LUA_OPIDIV"><code>LUA_OPIDIV</code></a>: </b> performs floor division (<code>//…
3627 <li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>: </b> performs modulo (<code>%</code>)</l…
3628 <li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>: </b> performs exponentiation (<code>^</c…
3629 <li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>: </b> performs mathematical negation (una…
3630 <li><b><a name="pdf-LUA_OPBNOT"><code>LUA_OPBNOT</code></a>: </b> performs bitwise NOT (<code>~</co…
3631 <li><b><a name="pdf-LUA_OPBAND"><code>LUA_OPBAND</code></a>: </b> performs bitwise AND (<code>&…
3632 <li><b><a name="pdf-LUA_OPBOR"><code>LUA_OPBOR</code></a>: </b> performs bitwise OR (<code>|</code>…
3633 <li><b><a name="pdf-LUA_OPBXOR"><code>LUA_OPBXOR</code></a>: </b> performs bitwise exclusive OR (<c…
3634 <li><b><a name="pdf-LUA_OPSHL"><code>LUA_OPSHL</code></a>: </b> performs left shift (<code><<…
3635 <li><b><a name="pdf-LUA_OPSHR"><code>LUA_OPSHR</code></a>: </b> performs right shift (<code>>>…
3643 <span class="apii">[-0, +0, –]</span>
3654 <span class="apii">[-(nargs+1), +nresults, <em>e</em>]</span>
3677 unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
3704 lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */
3705 lua_remove(L, -2); /* remove 't' from the stack */
3719 <span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
3786 <span class="apii">[-0, +0, –]</span>
3806 <span class="apii">[-0, +0, –]</span>
3810 Close all active to-be-closed variables in the main thread,
3812 (calling the corresponding garbage-collection metamethods, if any),
3819 On the other hand, long-running programs that create multiple states,
3828 <span class="apii">[-0, +0, <em>e</em>]</span>
3832 Close the to-be-closed slot at the given index and set its value to <b>nil</b>.
3850 <span class="apii">[-0, +?, –]</span>
3855 to-be-closed variables.
3857 <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> for no errors in the thread
3879 <span class="apii">[-0, +0, <em>e</em>]</span>
3897 <li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>: </b> compares for equality (<code>==</code…
3898 <li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>: </b> compares for less than (<code><</c…
3899 <li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code><…
3907 <span class="apii">[-n, +1, <em>e</em>]</span>
3924 <span class="apii">[-0, +0, –]</span>
3938 <span class="apii">[-0, +1, <em>m</em>]</span>
3957 <span class="apii">[-0, +0, –]</span>
3996 <span class="apii">[-1, +0, <em>v</em>]</span>
4011 <span class="apii">[-0, +0, –]</span>
4027 Performs a full garbage-collection cycle.
4071 see <a href="#pdf-collectgarbage"><code>collectgarbage</code></a>.
4082 <span class="apii">[-0, +0, –]</span>
4086 Returns the memory-allocation function of a given state.
4088 opaque pointer given when the memory-allocator function was set.
4095 <span class="apii">[-0, +1, <em>e</em>]</span>
4113 <span class="apii">[-0, +0, –]</span>
4138 <span class="apii">[-0, +1, <em>e</em>]</span>
4150 <span class="apii">[-0, +1, <em>e</em>]</span>
4168 <span class="apii">[-0, +(0|1), –]</span>
4182 <span class="apii">[-1, +1, <em>e</em>]</span>
4206 <span class="apii">[-0, +0, –]</span>
4220 <span class="apii">[-0, +1, –]</span>
4224 Pushes onto the stack the <code>n</code>-th user value associated with the
4231 pushes <b>nil</b> and returns <a href="#pdf-LUA_TNONE"><code>LUA_TNONE</code></a>.
4238 <span class="apii">[-1, +1, –]</span>
4244 This function cannot be called with a pseudo-index,
4245 because a pseudo-index is not an actual stack position.
4260 (usually a 64-bit two-complement integer),
4262 (usually a 32-bit two-complement integer).
4268 <a name="pdf-LUA_MININTEGER"><code>LUA_MININTEGER</code></a> and <a name="pdf-LUA_MAXINTEGER"><code…
4276 <span class="apii">[-0, +0, –]</span>
4288 <span class="apii">[-0, +0, –]</span>
4300 <span class="apii">[-0, +0, –]</span>
4312 <span class="apii">[-0, +0, –]</span>
4325 <span class="apii">[-0, +0, –]</span>
4337 <span class="apii">[-0, +0, –]</span>
4349 <span class="apii">[-0, +0, –]</span>
4361 <span class="apii">[-0, +0, –]</span>
4374 <span class="apii">[-0, +0, –]</span>
4387 <span class="apii">[-0, +0, –]</span>
4400 <span class="apii">[-0, +0, –]</span>
4412 <span class="apii">[-0, +0, –]</span>
4424 <span class="apii">[-0, +0, –]</span>
4436 <span class="apii">[-0, +0, –]</span>
4451 The type for continuation-function contexts.
4473 <span class="apii">[-0, +1, <em>e</em>]</span>
4487 <span class="apii">[-0, +1, –]</span>
4503 The <code>lua_load</code> function uses a user-supplied <code>reader</code> function
4516 The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>,
4529 <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>, <a href="#pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</co…
4547 <span class="apii">[-0, +0, –]</span>
4565 <span class="apii">[-0, +1, <em>m</em>]</span>
4577 <span class="apii">[-0, +1, <em>m</em>]</span>
4597 <span class="apii">[-0, +1, <em>m</em>]</span>
4620 <span class="apii">[-1, +(2|0), <em>v</em>]</span>
4638 /* uses 'key' (at index -2) and 'value' (at index -1) */
4639 printf("%s - %s\n",
4640 lua_typename(L, lua_type(L, -2)),
4641 lua_typename(L, lua_type(L, -1)));
4659 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
4704 <span class="apii">[-(nargs + 1), +(nresults|1), –]</span>
4731 (This index cannot be a pseudo-index.)
4747 …-LUA_OK"><code>LUA_OK</code></a>, <a href="#pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>, <a href="…
4754 <span class="apii">[-(nargs + 1), +(nresults|1), –]</span>
4771 <span class="apii">[-n, +0, <em>e</em>]</span>
4783 <span class="apii">[-0, +1, –]</span>
4794 <span class="apii">[-n, +1, <em>m</em>]</span>
4843 <span class="apii">[-0, +1, –]</span>
4855 <span class="apii">[-0, +1, <em>v</em>]</span>
4872 '<code>%s</code>' (inserts a zero-terminated string, with no size restrictions),
4877 '<code>%c</code>' (inserts an <code>int</code> as a one-byte character), and
4878 '<code>%U</code>' (inserts a <code>long int</code> as a UTF-8 byte sequence).
4890 <span class="apii">[-0, +1, –]</span>
4901 <span class="apii">[-0, +1, –]</span>
4912 <span class="apii">[-0, +1, –]</span>
4933 <span class="apii">[-0, +1, <em>m</em>]</span>
4946 <span class="apii">[-0, +1, <em>m</em>]</span>
4967 <span class="apii">[-0, +1, –]</span>
4978 <span class="apii">[-0, +1, –]</span>
4989 <span class="apii">[-0, +1, <em>m</em>]</span>
4993 Pushes the zero-terminated string pointed to by <code>s</code>
5012 <span class="apii">[-0, +1, –]</span>
5024 <span class="apii">[-0, +1, –]</span>
5036 <span class="apii">[-0, +1, <em>v</em>]</span>
5050 <span class="apii">[-0, +0, –]</span>
5065 <span class="apii">[-1, +1, –]</span>
5078 <span class="apii">[-0, +1, –]</span>
5096 <span class="apii">[-0, +1, –]</span>
5115 <span class="apii">[-0, +0, –]</span>
5132 <span class="apii">[-2, +0, <em>m</em>]</span>
5145 <span class="apii">[-1, +0, <em>m</em>]</span>
5164 <span class="apii">[-1, +0, <em>m</em>]</span>
5206 <span class="apii">[-0, +0, <em>e</em>]</span>
5222 <span class="apii">[-1, +0, –]</span>
5228 This function cannot be called with a pseudo-index,
5229 because a pseudo-index is not an actual stack position.
5236 <span class="apii">[-1, +0, –]</span>
5250 <span class="apii">[-0, +?, –]</span>
5263 <span class="apii">[-?, +?, –]</span>
5284 <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the coroutine yields,
5285 <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> if the coroutine finishes its execution
5309 <span class="apii">[-0, +0, –]</span>
5317 or <code>-n</code> positions in the direction of the bottom,
5321 This function cannot be called with a pseudo-index,
5322 because a pseudo-index is not an actual stack position.
5329 <span class="apii">[-0, +0, –]</span>
5341 <span class="apii">[-1, +0, <em>e</em>]</span>
5360 <span class="apii">[-1, +0, <em>e</em>]</span>
5372 <span class="apii">[-1, +0, <em>e</em>]</span>
5391 <span class="apii">[-1, +0, –]</span>
5396 the new <code>n</code>-th user value associated to the
5405 <span class="apii">[-1, +0, –]</span>
5423 <span class="apii">[-2, +0, <em>e</em>]</span>
5443 <span class="apii">[-?, +?, <em>e</em>]</span>
5456 marked as to-be-closed from the stack.
5463 <span class="apii">[-0, +0, –]</span>
5497 <span class="apii">[-0, +0, –]</span>
5505 The status can be <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> for a normal thread,
5508 or <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the thread is suspended.
5512 You can call functions only in threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>.
5513 You can resume threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>
5514 (to start a new coroutine) or <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a>
5522 <span class="apii">[-0, +1, –]</span>
5526 Converts the zero-terminated string <code>s</code> to a number,
5543 <span class="apii">[-0, +0, –]</span>
5561 <span class="apii">[-0, +0, –]</span>
5574 <span class="apii">[-0, +0, <em>m</em>]</span>
5579 to-be-closed slot (see <a href="#3.3.8">§3.3.8</a>).
5580 Like a to-be-closed variable in Lua,
5589 A slot marked as to-be-closed should not be removed from the stack
5596 that is equal to or below an active to-be-closed slot.
5611 <span class="apii">[-0, +0, –]</span>
5622 <span class="apii">[-0, +0, –]</span>
5643 <span class="apii">[-0, +0, <em>m</em>]</span>
5671 <span class="apii">[-0, +0, –]</span>
5682 <span class="apii">[-0, +0, –]</span>
5703 <span class="apii">[-0, +0, –]</span>
5723 <span class="apii">[-0, +0, <em>m</em>]</span>
5734 <span class="apii">[-0, +0, –]</span>
5748 <span class="apii">[-0, +0, –]</span>
5753 returns its memory-block address.
5763 <span class="apii">[-0, +0, –]</span>
5768 or <code>LUA_TNONE</code> for a non-valid but acceptable index.
5771 <a name="pdf-LUA_TNIL"><code>LUA_TNIL</code></a>,
5772 <a name="pdf-LUA_TNUMBER"><code>LUA_TNUMBER</code></a>,
5773 <a name="pdf-LUA_TBOOLEAN"><code>LUA_TBOOLEAN</code></a>,
5774 <a name="pdf-LUA_TSTRING"><code>LUA_TSTRING</code></a>,
5775 <a name="pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>,
5776 <a name="pdf-LUA_TFUNCTION"><code>LUA_TFUNCTION</code></a>,
5777 <a name="pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>,
5778 <a name="pdf-LUA_TTHREAD"><code>LUA_TTHREAD</code></a>,
5780 <a name="pdf-LUA_TLIGHTUSERDATA"><code>LUA_TLIGHTUSERDATA</code></a>.
5787 <span class="apii">[-0, +0, –]</span>
5788 <pre>const char *lua_typename (lua_State *L, int tp);</pre>
5791 Returns the name of the type encoded by the value <code>tp</code>,
5809 <span class="apii">[-0, +0, –]</span>
5813 Returns the pseudo-index that represents the <code>i</code>-th upvalue of
5822 <span class="apii">[-0, +0, –]</span>
5846 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5853 <span class="apii">[-0, +0, –]</span>
5863 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5895 <span class="apii">[-?, +?, –]</span>
5911 <span class="apii">[-?, +?, <em>v</em>]</span>
5928 <span class="apii">[-?, +?, <em>v</em>]</span>
5978 (what is called a <em>C-call boundary</em>),
5991 Lua has no built-in debugging facilities.
6045 the remainder of its contents describes the source in a user-dependent manner.
6076 <code>currentline</code> is set to -1.
6081 Because functions in Lua are first-class values,
6143 <span class="apii">[-0, +0, –]</span>
6154 <span class="apii">[-0, +0, –]</span>
6165 <span class="apii">[-0, +0, –]</span>
6176 <span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
6262 <span class="apii">[-0, +(0|1), –]</span>
6276 see <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for details about variable indices
6303 <span class="apii">[-0, +0, –]</span>
6326 <span class="apii">[-0, +(0|1), –]</span>
6330 Gets information about the <code>n</code>-th upvalue
6339 See <a href="#pdf-debug.getupvalue"><code>debug.getupvalue</code></a> for more information about up…
6356 <a name="pdf-LUA_HOOKCALL"><code>LUA_HOOKCALL</code></a>, <a name="pdf-LUA_HOOKRET"><code>LUA_HOOKR…
6357 <a name="pdf-LUA_HOOKTAILCALL"><code>LUA_HOOKTAILCALL</code></a>, <a name="pdf-LUA_HOOKLINE"><code>…
6358 and <a name="pdf-LUA_HOOKCOUNT"><code>LUA_HOOKCOUNT</code></a>.
6379 …allk</code></a>, or <a href="#lua_callk"><code>lua_callk</code></a> with a non-null <code>k</code>.
6394 <span class="apii">[-0, +0, –]</span>
6405 <a name="pdf-LUA_MASKCALL"><code>LUA_MASKCALL</code></a>,
6406 <a name="pdf-LUA_MASKRET"><code>LUA_MASKRET</code></a>,
6407 <a name="pdf-LUA_MASKLINE"><code>LUA_MASKLINE</code></a>,
6408 and <a name="pdf-LUA_MASKCOUNT"><code>LUA_MASKCOUNT</code></a>.
6444 <span class="apii">[-(0|1), +0, –]</span>
6468 <span class="apii">[-(0|1), +0, –]</span>
6492 <span class="apii">[-0, +0, –]</span>
6518 <span class="apii">[-0, +0, –]</span>
6523 Make the <code>n1</code>-th upvalue of the Lua closure at index <code>funcindex1</code>
6524 refer to the <code>n2</code>-th upvalue of the Lua closure at index <code>funcindex2</code>.
6542 the auxiliary library provides higher-level functions for some
6593 <span class="apii">[-?, +?, <em>m</em>]</span>
6605 <span class="apii">[-?, +?, <em>m</em>]</span>
6619 <span class="apii">[-?, +?, <em>m</em>]</span>
6633 <span class="apii">[-?, +?, –]</span>
6646 <span class="apii">[-?, +?, <em>m</em>]</span>
6650 Adds the zero-terminated string pointed to by <code>s</code>
6659 <span class="apii">[-?, +?, <em>m</em>]</span>
6679 <span class="apii">[-0, +0, <em>v</em>]</span>
6694 <span class="apii">[-0, +0, <em>v</em>]</span>
6713 <span class="apii">[-0, +0, <em>v</em>]</span>
6800 <span class="apii">[-0, +0, –]</span>
6813 <span class="apii">[-0, +?, –]</span>
6827 <span class="apii">[-0, +0, –]</span>
6839 <span class="apii">[-?, +?, <em>m</em>]</span>
6851 <span class="apii">[-?, +?, –]</span>
6864 <span class="apii">[-0, +(0|1), <em>e</em>]</span>
6885 <span class="apii">[-0, +0, <em>v</em>]</span>
6897 <span class="apii">[-0, +0, <em>v</em>]</span>
6910 <span class="apii">[-0, +0, <em>v</em>]</span>
6929 <span class="apii">[-0, +0, <em>v</em>]</span>
6941 <span class="apii">[-0, +0, <em>v</em>]</span>
6950 (which must be NULL-terminated).
6972 <span class="apii">[-0, +0, <em>v</em>]</span>
6986 <span class="apii">[-0, +0, <em>v</em>]</span>
7003 <span class="apii">[-0, +0, <em>v</em>]</span>
7015 <span class="apii">[-0, +0, <em>v</em>]</span>
7021 returns the userdata's memory-block address (see <a href="#lua_touserdata"><code>lua_touserdata</co…
7028 <span class="apii">[-0, +0, <em>v</em>]</span>
7040 <span class="apii">[-0, +?, <em>m</em>]</span>
7050 It returns 0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) if there are no errors,
7058 <span class="apii">[-0, +?, –]</span>
7068 It returns 0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) if there are no errors,
7076 <span class="apii">[-0, +0, <em>v</em>]</span>
7099 <span class="apii">[-0, +3, <em>m</em>]</span>
7104 process-related functions in the standard library
7105 (<a href="#pdf-os.execute"><code>os.execute</code></a> and <a href="#pdf-io.close"><code>io.close</…
7112 <span class="apii">[-0, +(1|3), <em>m</em>]</span>
7117 file-related functions in the standard library
7118 (<a href="#pdf-io.open"><code>io.open</code></a>, <a href="#pdf-os.rename"><code>os.rename</code></…
7125 <span class="apii">[-0, +(0|1), <em>m</em>]</span>
7140 <span class="apii">[-0, +1, <em>m</em>]</span>
7154 <span class="apii">[-0, +1, <em>e</em>]</span>
7170 <span class="apii">[-0, +1, <em>m</em>]</span>
7187 <span class="apii">[-0, +0, <em>e</em>]</span>
7202 <span class="apii">[-0, +1, –]</span>
7216 <span class="apii">[-0, +1, –]</span>
7240 <span class="apii">[-0, +1, <em>m</em>]</span>
7251 <span class="apii">[-0, +1, <em>m</em>]</span>
7270 or <a href="#pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a> for file-related errors.
7282 <span class="apii">[-0, +1, –]</span>
7288 the zero-terminated string <code>s</code>.
7304 <span class="apii">[-0, +1, <em>m</em>]</span>
7326 <span class="apii">[-0, +1, <em>m</em>]</span>
7347 <span class="apii">[-0, +1, <em>m</em>]</span>
7370 <span class="apii">[-0, +0, –]</span>
7390 <span class="apii">[-0, +0, <em>e</em>]</span>
7401 <span class="apii">[-0, +0, –]</span>
7422 <span class="apii">[-0, +0, <em>v</em>]</span>
7440 <span class="apii">[-0, +0, <em>v</em>]</span>
7471 <span class="apii">[-0, +0, <em>v</em>]</span>
7486 <span class="apii">[-0, +0, <em>v</em>]</span>
7503 <span class="apii">[-?, +?, <em>m</em>]</span>
7508 with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
7515 <span class="apii">[-?, +?, <em>m</em>]</span>
7531 <span class="apii">[-0, +1, –]</span>
7542 <span class="apii">[-?, +1, <em>m</em>]</span>
7554 <span class="apii">[-?, +1, <em>m</em>]</span>
7565 <span class="apii">[-1, +0, <em>m</em>]</span>
7585 <a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <a name="pdf-LUA_REFNIL"><code>L…
7586 The constant <a name="pdf-LUA_NOREF"><code>LUA_NOREF</code></a> is guaranteed to be different
7612 <span class="apii">[-0, +1, <em>e</em>]</span>
7620 as if that function has been called through <a href="#pdf-require"><code>require</code></a>.
7636 <span class="apii">[-nup, +0, <em>m</em>]</span>
7663 <span class="apii">[-0, +0, –]</span>
7714 <span class="apii">[-0, +0, <em>m</em>]</span>
7727 <span class="apii">[-0, +1, <em>e</em>]</span>
7750 <span class="apii">[-0, +1, <em>m</em>]</span>
7766 <span class="apii">[-0, +0, <em>v</em>]</span>
7781 <span class="apii">[-0, +0, –]</span>
7792 <span class="apii">[-0, +0, –]</span>
7804 If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a href="#pdf-LUA_REF…
7812 <span class="apii">[-0, +1, <em>m</em>]</span>
7845 (e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable…
7849 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
7856 these library functions do not adjust its number of arguments
7884 <li>basic UTF-8 support (<a href="#6.5">§6.5</a>);</li>
7909 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
7910 <a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
7911 <a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),
7912 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
7913 <a name="pdf-luaopen_utf8"><code>luaopen_utf8</code></a> (for the UTF-8 library),
7914 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
7915 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
7916 <a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
7917 <a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the operating system library),
7918 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
7919 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
7935 <hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
7950 <hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>
7960 Performs a full garbage-collection cycle.
7982 Performs a garbage-collection step.
7986 For non-zero values,
8000 the garbage-collector pause,
8009 the garbage-collector minor multiplier
8026 <hr><h3><a name="pdf-dofile"><code>dofile ([filename])</code></a></h3>
8039 <hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
8059 <hr><h3><a name="pdf-_G"><code>_G</code></a></h3>
8070 <hr><h3><a name="pdf-getmetatable"><code>getmetatable (object)</code></a></h3>
8084 <hr><h3><a name="pdf-ipairs"><code>ipairs (t)</code></a></h3>
8102 <hr><h3><a name="pdf-load"><code>load (chunk [, chunkname [, mode [, env]]])</code></a></h3>
8129 when you load a binary chunk created from a function (see <a href="#pdf-string.dump"><code>string.d…
8133 (A non-main function may not even have an <code>_ENV</code> upvalue.)
8174 <hr><h3><a name="pdf-loadfile"><code>loadfile ([filename [, mode [, env]]])</code></a></h3>
8178 Similar to <a href="#pdf-load"><code>load</code></a>,
8187 <hr><h3><a name="pdf-next"><code>next (table [, index])</code></a></h3>
8215 You should not assign any value to a non-existent field in a table
8224 <hr><h3><a name="pdf-pairs"><code>pairs (t)</code></a></h3>
8235 returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</co…
8245 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
8252 <hr><h3><a name="pdf-pcall"><code>pcall (f [, arg1, ···])</code></a></h3>
8272 <hr><h3><a name="pdf-print"><code>print (···)</code></a></h3>
8276 following the same rules of <a href="#pdf-tostring"><code>tostring</code></a>.
8284 use <a href="#pdf-string.format"><code>string.format</code></a> and <a href="#pdf-io.write"><code>i…
8290 <hr><h3><a name="pdf-rawequal"><code>rawequal (v1, v2)</code></a></h3>
8299 <hr><h3><a name="pdf-rawget"><code>rawget (table, index)</code></a></h3>
8309 <hr><h3><a name="pdf-rawlen"><code>rawlen (v)</code></a></h3>
8319 <hr><h3><a name="pdf-rawset"><code>rawset (table, index, value)</code></a></h3>
8334 <hr><h3><a name="pdf-select"><code>select (index, ···)</code></a></h3>
8340 a negative number indexes from the end (-1 is the last argument).
8348 <hr><h3><a name="pdf-setmetatable"><code>setmetatable (table, metatable)</code></a></h3>
8371 <hr><h3><a name="pdf-tonumber"><code>tonumber (e [, base])</code></a></h3>
8404 <hr><h3><a name="pdf-tostring"><code>tostring (v)</code></a></h3>
8409 converts it to a string in a human-readable format.
8424 use <a href="#pdf-string.format"><code>string.format</code></a>.
8430 <hr><h3><a name="pdf-type"><code>type (v)</code></a></h3>
8449 <hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
8461 <hr><h3><a name="pdf-warn"><code>warn (msg1, ···)</code></a></h3>
8471 a one-piece message starting with '<code>@</code>'
8484 <hr><h3><a name="pdf-xpcall"><code>xpcall (f, msgh [, arg1, ···])</code></a></…
8488 This function is similar to <a href="#pdf-pcall"><code>pcall</code></a>,
8501 which come inside the table <a name="pdf-coroutine"><code>coroutine</code></a>.
8506 <hr><h3><a name="pdf-coroutine.close"><code>coroutine.close (co)</code></a></h3>
8512 closes all its pending to-be-closed variables
8525 <hr><h3><a name="pdf-coroutine.create"><code>coroutine.create (f)</code></a></h3>
8538 <hr><h3><a name="pdf-coroutine.isyieldable"><code>coroutine.isyieldable ([co])</code></a></h3>
8548 it is not inside a non-yieldable C function.
8554 <hr><h3><a name="pdf-coroutine.resume"><code>coroutine.resume (co [, val1, ···…
8581 <hr><h3><a name="pdf-coroutine.running"><code>coroutine.running ()</code></a></h3>
8592 <hr><h3><a name="pdf-coroutine.status"><code>coroutine.status (co)</code></a></h3>
8611 <hr><h3><a name="pdf-coroutine.wrap"><code>coroutine.wrap (f)</code></a></h3>
8629 <hr><h3><a name="pdf-coroutine.yield"><code>coroutine.yield (···)</code></a></…
8648 <a href="#pdf-require"><code>require</code></a>.
8649 Everything else is exported in the table <a name="pdf-package"><code>package</code></a>.
8653 <hr><h3><a name="pdf-require"><code>require (modname)</code></a></h3>
8658 The function starts by looking into the <a href="#pdf-package.loaded"><code>package.loaded</code></…
8669 <code>require</code> is guided by the table <a href="#pdf-package.searchers"><code>package.searcher…
8675 for <a href="#pdf-package.searchers"><code>package.searchers</code></a>.
8683 path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
8685 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
8687 it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.searchers"><code>package.searcher…
8701 If the loader returns any non-nil value,
8703 If the loader does not return a non-nil value and
8722 <hr><h3><a name="pdf-package.config"><code>package.config</code></a></h3>
8726 A string describing some compile-time configurations for packages.
8747 Default is '<code>-</code>'.</li>
8754 <hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
8758 A string with the path used by <a href="#pdf-require"><code>require</code></a>
8763 Lua initializes the C path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the …
8764 it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
8765 using the environment variable <a name="pdf-LUA_CPATH_5_4"><code>LUA_CPATH_5_4</code></a>,
8766 or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>,
8773 <hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
8777 A table used by <a href="#pdf-require"><code>require</code></a> to control which
8781 <a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
8787 table used by <a href="#pdf-require"><code>require</code></a>.
8789 indexed by the key <a name="pdf-LUA_LOADED_TABLE"><code>LUA_LOADED_TABLE</code></a>, a string.
8795 <hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
8815 This is a low-level function.
8817 Unlike <a href="#pdf-require"><code>require</code></a>,
8848 <hr><h3><a name="pdf-package.path"><code>package.path</code></a></h3>
8852 A string with the path used by <a href="#pdf-require"><code>require</code></a>
8857 At start-up, Lua initializes this variable with
8858 the value of the environment variable <a name="pdf-LUA_PATH_5_4"><code>LUA_PATH_5_4</code></a> or
8859 the environment variable <a name="pdf-LUA_PATH"><code>LUA_PATH</code></a> or
8869 <hr><h3><a name="pdf-package.preload"><code>package.preload</code></a></h3>
8874 (see <a href="#pdf-require"><code>require</code></a>).
8880 table used by <a href="#pdf-require"><code>require</code></a>.
8882 indexed by the key <a name="pdf-LUA_PRELOAD_TABLE"><code>LUA_PRELOAD_TABLE</code></a>, a string.
8888 <hr><h3><a name="pdf-package.searchers"><code>package.searchers</code></a></h3>
8892 A table used by <a href="#pdf-require"><code>require</code></a> to control how to find modules.
8898 <a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
8899 with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
8905 returned as a second result by <a href="#pdf-require"><code>require</code></a>.
8917 <a href="#pdf-package.preload"><code>package.preload</code></a> table.
8922 using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
8923 The search is done as described in function <a href="#pdf-package.searchpath"><code>package.searchp…
8928 using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
8930 the search is done as described in function <a href="#pdf-package.searchpath"><code>package.searchp…
8950 For instance, if the module name is <code>a.b.c-v2.1</code>,
8955 The fourth searcher tries an <em>all-in-one loader</em>.
8971 as returned by <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
8984 <hr><h3><a name="pdf-package.searchpath"><code>package.searchpath (name, path [, sep [, rep]])</cod…
9039 Thus, the last character is at position -1, and so on.
9044 <a name="pdf-string"><code>string</code></a>.
9047 Therefore, you can use the string functions in object-oriented style.
9053 The string library assumes one-byte character encodings.
9057 <hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
9063 following the same rules of function <a href="#pdf-string.sub"><code>string.sub</code></a>.
9073 <hr><h3><a name="pdf-string.char"><code>string.char (···)</code></a></h3>
9087 <hr><h3><a name="pdf-string.dump"><code>string.dump (function [, strip])</code></a></h3>
9094 so that a later <a href="#pdf-load"><code>load</code></a> on this string returns
9106 (See the <a href="#pdf-load"><code>load</code></a> function for details about
9116 <hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
9144 <hr><h3><a name="pdf-string.format"><code>string.format (formatstring, ···)</c…
9198 it is converted to one following the same rules of <a href="#pdf-tostring"><code>tostring</code></a…
9216 <hr><h3><a name="pdf-string.gmatch"><code>string.gmatch (s, pattern [, init])</code></a></h3>
9258 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
9274 stands for the value of the <em>d</em>-th captured substring;
9310 --> x="hello hello world world"
9313 --> x="hello hello world"
9316 --> x="world hello Lua from"
9319 --> x="home = /home/roberto, user = roberto"
9321 x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
9324 --> x="4+5 = 9"
9327 x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
9328 --> x="lua-5.4.tar.gz"
9334 <hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
9347 <hr><h3><a name="pdf-string.lower"><code>string.lower (s)</code></a></h3>
9360 <hr><h3><a name="pdf-string.match"><code>string.match (s, pattern [, init])</code></a></h3>
9379 <hr><h3><a name="pdf-string.pack"><code>string.pack (fmt, v1, v2, ···)</code><…
9391 <hr><h3><a name="pdf-string.packsize"><code>string.packsize (fmt)</code></a></h3>
9395 Returns the length of a string resulting from <a href="#pdf-string.pack"><code>string.pack</code></…
9397 The format string cannot have the variable-length options
9404 <hr><h3><a name="pdf-string.rep"><code>string.rep (s, n [, sep])</code></a></h3>
9423 <hr><h3><a name="pdf-string.reverse"><code>string.reverse (s)</code></a></h3>
9433 <hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
9440 If <code>j</code> is absent, then it is assumed to be equal to -1
9445 and <code>string.sub(s, -i)</code> (for a positive <code>i</code>)
9464 <hr><h3><a name="pdf-string.unpack"><code>string.unpack (fmt, s [, pos])</code></a></h3>
9468 Returns the values packed in string <code>s</code> (see <a href="#pdf-string.pack"><code>string.pac…
9479 <hr><h3><a name="pdf-string.upper"><code>string.upper (s)</code></a></h3>
9500 which are interpreted as patterns by the pattern-matching functions
9501 <a href="#pdf-string.find"><code>string.find</code></a>,
9502 <a href="#pdf-string.gmatch"><code>string.gmatch</code></a>,
9503 <a href="#pdf-string.gsub"><code>string.gsub</code></a>,
9504 and <a href="#pdf-string.match"><code>string.match</code></a>.
9520 <code>^$()%.[]*+-?</code>)
9546 <li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character)
9549 Any non-alphanumeric character
9550 (including all punctuation characters, even the non-magical)
9559 in ascending order, with a '<code>-</code>'.
9565 <code>[0-7]</code> represents the octal digits,
9566 and <code>[0-7%l%-]</code> represents the octal digits plus
9567 the lowercase letters plus the '<code>-</code>' character.
9580 Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code>
9592 For instance, <code>%S</code> represents all non-space characters.
9598 In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.
9627 a single character class followed by '<code>-</code>',
9641 such item matches a substring equal to the <em>n</em>-th captured string
9650 counting <em>+1</em> for an <em>x</em> and <em>-1</em> for a <em>y</em>,
9685 A pattern can contain sub-patterns enclosed in parentheses;
9708 The function <a href="#pdf-string.gsub"><code>string.gsub</code></a> and the iterator <a href="#pdf…
9720 --> 1 2
9721 --> 3 3
9722 --> 4 4
9738 The first argument to <a href="#pdf-string.pack"><code>string.pack</code></a>,
9739 <a href="#pdf-string.packsize"><code>string.packsize</code></a>, and <a href="#pdf-string.unpack"><…
9770 <li><b><code>c<em>n</em></code>: </b>a fixed-sized string with <code>n</code> bytes</li>
9771 <li><b><code>z</code>: </b>a zero-terminated string</li>
9784 each option corresponds to an argument in <a href="#pdf-string.pack"><code>string.pack</code></a>
9785 or a result in <a href="#pdf-string.unpack"><code>string.unpack</code></a>.
9792 <a href="#pdf-string.pack"><code>string.pack</code></a> checks whether the given value fits in the …
9793 <a href="#pdf-string.unpack"><code>string.unpack</code></a> checks whether the read value fits in a…
9809 of mixed-endian formats.
9824 All padding is filled with zeros by <a href="#pdf-string.pack"><code>string.pack</code></a>
9825 and ignored by <a href="#pdf-string.unpack"><code>string.unpack</code></a>.
9833 <h2>6.5 – <a name="6.5">UTF-8 Support</a></h2>
9836 This library provides basic support for UTF-8 encoding.
9837 It provides all its functions inside the table <a name="pdf-utf8"><code>utf8</code></a>.
9856 as defined in the original UTF-8 specification;
9873 <hr><h3><a name="pdf-utf8.char"><code>utf8.char (···)</code></a></h3>
9878 converts each one to its corresponding UTF-8 byte sequence
9885 <hr><h3><a name="pdf-utf8.charpattern"><code>utf8.charpattern</code></a></h3>
9889 The pattern (a string, not a function) "<code>[\0-\x7F\xC2-\xFD][\x80-\xBF]*</code>"
9891 which matches exactly one UTF-8 byte sequence,
9892 assuming that the subject is a valid UTF-8 string.
9898 <hr><h3><a name="pdf-utf8.codes"><code>utf8.codes (s [, lax])</code></a></h3>
9907 will iterate over all UTF-8 characters in string <code>s</code>,
9916 <hr><h3><a name="pdf-utf8.codepoint"><code>utf8.codepoint (s [, i [, j [, lax]]])</code></a></h3>
9929 <hr><h3><a name="pdf-utf8.len"><code>utf8.len (s [, i [, j [, lax]]])</code></a></h3>
9933 Returns the number of UTF-8 characters in string <code>s</code>
9935 The default for <code>i</code> is 1 and for <code>j</code> is -1.
9943 <hr><h3><a name="pdf-utf8.offset"><code>utf8.offset (s, n [, i])</code></a></h3>
9948 <code>n</code>-th character of <code>s</code>
9951 The default for <code>i</code> is 1 when <code>n</code> is non-negative
9953 so that <code>utf8.offset(s, -n)</code> gets the offset of the
9954 <code>n</code>-th character from the end of the string.
9963 of the character that contains the <code>i</code>-th byte of <code>s</code>.
9967 This function assumes that <code>s</code> is a valid UTF-8 string.
9979 It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.
9985 All functions ignore non-numeric keys
9990 <hr><h3><a name="pdf-table.concat"><code>table.concat (list [, sep [, i [, j]]])</code></a></h3>
10005 <hr><h3><a name="pdf-table.insert"><code>table.insert (list, [pos,] value)</code></a></h3>
10020 <hr><h3><a name="pdf-table.move"><code>table.move (a1, f, e, t [,a2])</code></a></h3>
10040 <hr><h3><a name="pdf-table.pack"><code>table.pack (···)</code></a></h3>
10053 <hr><h3><a name="pdf-table.remove"><code>table.remove (list [, pos])</code></a></h3>
10076 <hr><h3><a name="pdf-table.sort"><code>table.sort (list [, comp])</code></a></h3>
10080 Sorts the list elements in a given order, <em>in-place</em>,
10108 <hr><h3><a name="pdf-table.unpack"><code>table.unpack (list [, i [, j]])</code></a></h3>
10130 It provides all its functions and constants inside the table <a name="pdf-math"><code>math</code></…
10133 and float results for non-integer arguments.
10135 <a href="#pdf-math.ceil"><code>math.ceil</code></a>, <a href="#pdf-math.floor"><code>math.floor</co…
10141 <hr><h3><a name="pdf-math.abs"><code>math.abs (x)</code></a></h3>
10145 Returns the maximum value between <code>x</code> and <code>-x</code>. (integer/float)
10151 <hr><h3><a name="pdf-math.acos"><code>math.acos (x)</code></a></h3>
10161 <hr><h3><a name="pdf-math.asin"><code>math.asin (x)</code></a></h3>
10171 <hr><h3><a name="pdf-math.atan"><code>math.atan (y [, x])</code></a></h3>
10191 <hr><h3><a name="pdf-math.ceil"><code>math.ceil (x)</code></a></h3>
10201 <hr><h3><a name="pdf-math.cos"><code>math.cos (x)</code></a></h3>
10211 <hr><h3><a name="pdf-math.deg"><code>math.deg (x)</code></a></h3>
10221 <hr><h3><a name="pdf-math.exp"><code>math.exp (x)</code></a></h3>
10232 <hr><h3><a name="pdf-math.floor"><code>math.floor (x)</code></a></h3>
10242 <hr><h3><a name="pdf-math.fmod"><code>math.fmod (x, y)</code></a></h3>
10253 <hr><h3><a name="pdf-math.huge"><code>math.huge</code></a></h3>
10264 <hr><h3><a name="pdf-math.log"><code>math.log (x [, base])</code></a></h3>
10276 <hr><h3><a name="pdf-math.max"><code>math.max (x, ···)</code></a></h3>
10287 <hr><h3><a name="pdf-math.maxinteger"><code>math.maxinteger</code></a></h3>
10294 <hr><h3><a name="pdf-math.min"><code>math.min (x, ···)</code></a></h3>
10305 <hr><h3><a name="pdf-math.mininteger"><code>math.mininteger</code></a></h3>
10312 <hr><h3><a name="pdf-math.modf"><code>math.modf (x)</code></a></h3>
10323 <hr><h3><a name="pdf-math.pi"><code>math.pi</code></a></h3>
10333 <hr><h3><a name="pdf-math.rad"><code>math.rad (x)</code></a></h3>
10343 <hr><h3><a name="pdf-math.random"><code>math.random ([m [, n]])</code></a></h3>
10348 returns a pseudo-random float with uniform distribution
10351 <code>math.random</code> returns a pseudo-random integer
10361 pseudo-random 64-bit integers,
10368 Lua initializes its pseudo-random generator with the equivalent of
10369 a call to <a href="#pdf-math.randomseed"><code>math.randomseed</code></a> with no arguments,
10377 <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed ([x [, y]])</code></a></h3>
10383 joined into a 128-bit <em>seed</em> that
10384 is used to reinitialize the pseudo-random generator;
10405 you should call <a href="#pdf-math.randomseed"><code>math.randomseed</code></a> with explicit argum…
10411 <hr><h3><a name="pdf-math.sin"><code>math.sin (x)</code></a></h3>
10421 <hr><h3><a name="pdf-math.sqrt"><code>math.sqrt (x)</code></a></h3>
10432 <hr><h3><a name="pdf-math.tan"><code>math.tan (x)</code></a></h3>
10442 <hr><h3><a name="pdf-math.tointeger"><code>math.tointeger (x)</code></a></h3>
10454 <hr><h3><a name="pdf-math.type"><code>math.type (x)</code></a></h3>
10466 <hr><h3><a name="pdf-math.ult"><code>math.ult (m, n)</code></a></h3>
10493 all operations are supplied by table <a name="pdf-io"><code>io</code></a>.
10495 the operation <a href="#pdf-io.open"><code>io.open</code></a> returns a file handle
10508 <a name="pdf-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a…
10516 a system-dependent error code as a third result,
10517 and some non-false value on success.
10518 On non-POSIX systems,
10526 <hr><h3><a name="pdf-io.close"><code>io.close ([file])</code></a></h3>
10537 <hr><h3><a name="pdf-io.flush"><code>io.flush ()</code></a></h3>
10547 <hr><h3><a name="pdf-io.input"><code>io.input ([file])</code></a></h3>
10567 <hr><h3><a name="pdf-io.lines"><code>io.lines ([filename, ···])</code></a></h3>
10601 <hr><h3><a name="pdf-io.open"><code>io.open (filename [, mode])</code></a></h3>
10630 <hr><h3><a name="pdf-io.output"><code>io.output ([file])</code></a></h3>
10634 Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output …
10640 <hr><h3><a name="pdf-io.popen"><code>io.popen (prog [, mode])</code></a></h3>
10659 <hr><h3><a name="pdf-io.read"><code>io.read (···)</code></a></h3>
10669 <hr><h3><a name="pdf-io.tmpfile"><code>io.tmpfile ()</code></a></h3>
10682 <hr><h3><a name="pdf-io.type"><code>io.type (obj)</code></a></h3>
10695 <hr><h3><a name="pdf-io.write"><code>io.write (···)</code></a></h3>
10705 <hr><h3><a name="pdf-file:close"><code>file:close ()</code></a></h3>
10716 When closing a file handle created with <a href="#pdf-io.popen"><code>io.popen</code></a>,
10717 <a href="#pdf-file:close"><code>file:close</code></a> returns the same values
10718 returned by <a href="#pdf-os.execute"><code>os.execute</code></a>.
10724 <hr><h3><a name="pdf-file:flush"><code>file:flush ()</code></a></h3>
10734 <hr><h3><a name="pdf-file:lines"><code>file:lines (···)</code></a></h3>
10750 Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
10757 <hr><h3><a name="pdf-file:read"><code>file:read (···)</code></a></h3>
10785 (e.g., an empty string, "<code>0x</code>", or "<code>3.4e-</code>")
10803 reads the next line keeping the end-of-line character (if present),
10822 <hr><h3><a name="pdf-file:seek"><code>file:seek ([whence [, offset]])</code></a></h3>
10856 <hr><h3><a name="pdf-file:setvbuf"><code>file:setvbuf (mode [, size])</code></a></h3>
10884 <hr><h3><a name="pdf-file:write"><code>file:write (···)</code></a></h3>
10904 This library is implemented through table <a name="pdf-os"><code>os</code></a>.
10908 <hr><h3><a name="pdf-os.clock"><code>os.clock ()</code></a></h3>
10920 <hr><h3><a name="pdf-os.date"><code>os.date ([format [, time]])</code></a></h3>
10931 (see the <a href="#pdf-os.time"><code>os.time</code></a> function for a description of this value).
10959 which gives a human-readable date and time representation
10964 On non-POSIX systems,
10972 <hr><h3><a name="pdf-os.difftime"><code>os.difftime (t2, t1)</code></a></h3>
10978 (where the times are values returned by <a href="#pdf-os.time"><code>os.time</code></a>).
10980 this value is exactly <code>t2</code><em>-</em><code>t1</code>.
10986 <hr><h3><a name="pdf-os.execute"><code>os.execute ([command])</code></a></h3>
11021 <hr><h3><a name="pdf-os.exit"><code>os.exit ([code [, close]])</code></a></h3>
11043 <hr><h3><a name="pdf-os.getenv"><code>os.getenv (varname)</code></a></h3>
11054 <hr><h3><a name="pdf-os.remove"><code>os.remove (filename)</code></a></h3>
11068 <hr><h3><a name="pdf-os.rename"><code>os.rename (oldname, newname)</code></a></h3>
11081 <hr><h3><a name="pdf-os.setlocale"><code>os.setlocale (locale [, category])</code></a></h3>
11086 <code>locale</code> is a system-dependent string specifying a locale;
11097 the current locale is set to an implementation-defined native locale.
11116 <hr><h3><a name="pdf-os.time"><code>os.time ([table])</code></a></h3>
11129 For a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function.
11135 For instance, if <code>sec</code> is -10,
11148 <a href="#pdf-os.date"><code>os.date</code></a> and <a href="#pdf-os.difftime"><code>os.difftime</c…
11154 documented in the <a href="#pdf-os.date"><code>os.date</code></a> function,
11162 <hr><h3><a name="pdf-os.tmpname"><code>os.tmpname ()</code></a></h3>
11184 you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
11211 inside the <a name="pdf-debug"><code>debug</code></a> table.
11219 <hr><h3><a name="pdf-debug.debug"><code>debug.debug ()</code></a></h3>
11240 <hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
11247 as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function.
11257 <hr><h3><a name="pdf-debug.getinfo"><code>debug.getinfo ([thread,] f [, what])</code></a></h3>
11294 about the <a href="#pdf-print"><code>print</code></a> function.
11300 <hr><h3><a name="pdf-debug.getlocal"><code>debug.getlocal ([thread,] f, local)</code></a></h3>
11315 Compile-time constants may not appear in this listing,
11318 -1 is the first vararg argument.
11322 (You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the leve…
11340 <hr><h3><a name="pdf-debug.getmetatable"><code>debug.getmetatable (value)</code></a></h3>
11351 <hr><h3><a name="pdf-debug.getregistry"><code>debug.getregistry ()</code></a></h3>
11361 <hr><h3><a name="pdf-debug.getupvalue"><code>debug.getupvalue (f, up)</code></a></h3>
11391 <hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u, n)</code></a></h3>
11395 Returns the <code>n</code>-th user value associated
11403 <hr><h3><a name="pdf-debug.sethook"><code>debug.sethook ([thread,] hook, mask [, count])</code></a>…
11425 <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> turns off the hook.
11445 <hr><h3><a name="pdf-debug.setlocal"><code>debug.setlocal ([thread,] level, local, value)</code></a…
11459 See <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for more information about
11466 <hr><h3><a name="pdf-debug.setmetatable"><code>debug.setmetatable (value, table)</code></a></h3>
11478 <hr><h3><a name="pdf-debug.setupvalue"><code>debug.setupvalue (f, up, value)</code></a></h3>
11490 See <a href="#pdf-debug.getupvalue"><code>debug.getupvalue</code></a> for more information about up…
11496 <hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value, n)</code></a></h3>
11501 the <code>n</code>-th user value associated to the given <code>udata</code>.
11513 <hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code><…
11531 <hr><h3><a name="pdf-debug.upvalueid"><code>debug.upvalueid (f, n)</code></a></h3>
11551 <hr><h3><a name="pdf-debug.upvaluejoin"><code>debug.upvaluejoin (f1, n1, f2, n2)</code></a></h3>
11555 Make the <code>n1</code>-th upvalue of the Lua closure <code>f1</code>
11556 refer to the <code>n2</code>-th upvalue of the Lua closure <code>f2</code>.
11583 <li><b><code>-e <em>stat</em></code>: </b> execute string <em>stat</em>;</li>
11584 <li><b><code>-i</code>: </b> enter interactive mode after running <em>script</em>;</li>
11585 <li><b><code>-l <em>mod</em></code>: </b> "require" <em>mod</em> and assign the
11587 <li><b><code>-l <em>g=mod</em></code>: </b> "require" <em>mod</em> and assign the
11589 <li><b><code>-v</code>: </b> print version information;</li>
11590 <li><b><code>-E</code>: </b> ignore environment variables;</li>
11591 <li><b><code>-W</code>: </b> turn warnings on;</li>
11592 <li><b><code>--</code>: </b> stop handling options;</li>
11593 <li><b><code>-</code>: </b> execute <code>stdin</code> as a file and stop handling options.</li>
11595 (The form <code>-l <em>g=mod</em></code> was introduced in release 5.4.4.)
11601 <code>lua</code> behaves as <code>lua -v -i</code>
11603 and as <code>lua -</code> otherwise.
11607 When called without the option <code>-E</code>,
11608 the interpreter checks for an environment variable <a name="pdf-LUA_INIT_5_4"><code>LUA_INIT_5_4</c…
11609 (or <a name="pdf-LUA_INIT"><code>LUA_INIT</code></a> if the versioned name is not defined)
11617 When called with the option <code>-E</code>,
11620 the values of <a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.c…
11625 The options <code>-e</code>, <code>-l</code>, and <code>-W</code> are handled in
11630 $ lua -e 'a=1' -llib1 script.lua
11639 <code>lua</code> collects all command-line arguments
11650 $ lua -la b.lua t1 t2
11655 arg = { [-2] = "lua", [-1] = "-la",
11665 $ lua -e "print(arg[1])"
11667 will print "<code>-e</code>".
11688 If the global variable <a name="pdf-_PROMPT"><code>_PROMPT</code></a> contains a string,
11690 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a strin…
11712 calling <a href="#pdf-os.exit"><code>os.exit</code></a> to terminate.
11763 do not imply source-code changes in a program,
11834 (Non-callable values will generate a warning,
11847 The function <a href="#pdf-print"><code>print</code></a> does not call <a href="#pdf-tostring"><cod…
11854 The pseudo-random number generator used by the function <a href="#pdf-math.random"><code>math.rando…
11860 By default, the decoding functions in the <a href="#pdf-utf8"><code>utf8</code></a> library
11867 of the function <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> are deprecated.
11872 The function <a href="#pdf-io.lines"><code>io.lines</code></a> now returns four values,
11879 to adjust its number of results to one.
11905 are more efficient memory-wise.
12020 …binop ::= ‘<b>+</b>’ | ‘<b>-</b>’ | ‘<b>*</b>’ | ‘<b>/<…
12025 unop ::= ‘<b>-</b>’ | <b>not</b> | ‘<b>#</b>’ | ‘<b>~</b>’
12041 <!--
12043 -->