Lines Matching +full:pre +full:- +full:its
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.)
92 as stated in its license.
129 All values in Lua are first-class values.
146 Despite its name,
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,
330 so changing its value will affect only your own code.)
335 the default value for its <code>_ENV</code> variable
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…
345 of its first upvalue; see <a href="#lua_setupvalue"><code>lua_setupvalue</code></a>.)
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…
370 Any error while running the function stops its execution,
396 It is up to the Lua program or its host to handle such error objects.
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>).
440 of a value by setting specific fields in its metatable.
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.
485 Each event is identified by its corresponding key.
510 the subtraction (<code>-</code>) operation.
535 the negation (unary <code>-</code>) operation.
588 Lua will try its metamethod.
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
677 the metamethod is called with <code>func</code> as its first argument,
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>)
723 right after its creation.
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
908 You mark an object for finalization when you set its metatable
924 Lua calls it with the object as its single argument.
928 At the end of each garbage-collection cycle,
943 and the object memory is freed in the next garbage-collection cycle.
948 its finalizer will be called again in the next cycle where the
968 its associated resource.
992 A table with weak values allows the collection of its values,
993 but prevents the collection of its keys.
999 <code>__mode</code> field of its metatable.
1010 a value is considered reachable only if its key is reachable.
1012 if the only reference to a key comes through its value,
1067 a coroutine only suspends its execution by explicitly calling
1072 You create a coroutine by calling <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
1073 Its sole argument is a function
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>,
1083 passing as its first argument
1084 a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
1085 the coroutine starts its execution by
1086 calling its main function.
1087 Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are pas…
1094 A coroutine can terminate its execution in two ways:
1095 normally, when its main function returns
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…
1103 In this case, the coroutine does not unwind its stack,
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>.
1118 it continues its execution from the point where it yielded,
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…
1143 <pre>
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)
1162 </pre><p>
1165 <pre>
1166 co-body 1 10
1169 co-body r
1170 main true 11 -9
1171 co-body x y
1174 </pre>
1203 Non-terminals are shown like non-terminal,
1216 Lua is a free-form language.
1229 Arabic-Indic digits, and underscores,
1240 <pre>
1245 </pre>
1248 Lua is a case-sensitive language:
1254 one or more uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>).
1260 <pre>
1261 + - * / % ^ #
1266 </pre>
1271 and can contain the following C-like escape sequences:
1297 by its numeric value.
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
1351 <pre>
1360 </pre>
1370 explicit escape sequences for the non-text characters.
1391 if its value fits in an integer or it is a hexadecimal constant,
1404 <pre>
1406 </pre><p>
1409 <pre>
1410 3.0 3.1416 314.16e-2 0.31416E1 34e1
1411 0x0.1E 0xA23p-4 0X1.921FB54442D18P+1
1412 </pre>
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,
1440 <pre>
1442 </pre><p>
1455 Before the first assignment to a variable, its value is <b>nil</b>.
1461 <pre>
1463 </pre><p>
1472 <pre>
1474 </pre>
1507 <pre>
1509 </pre><p>
1515 <pre>
1517 </pre>
1525 <pre>
1528 </pre><p>
1531 <pre>
1535 </pre><p>
1544 <pre>
1546 </pre>
1551 <pre>
1553 </pre><p>
1571 <pre>
1573 </pre>
1583 The resulting function always has <code>_ENV</code> as its only external variable,
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…
1615 <pre>
1619 </pre><p>
1636 <pre>
1639 </pre><p>
1645 <pre>
1647 </pre><p>
1651 <pre>
1653 </pre><p>
1688 <pre>
1692 </pre><p>
1719 <pre>
1723 </pre>
1741 <pre>
1743 </pre><p>
1755 <pre>
1757 </pre>
1765 because now <b>return</b> is the last statement in its (inner) block.
1787 <pre>
1789 </pre><p>
1807 Beware of floating-point accuracy in this case.
1835 If you need its value after the loop,
1851 <pre>
1854 </pre><p>
1857 <pre>
1859 </pre><p>
1891 to-be-closed variable (see <a href="#3.3.8">§3.3.8</a>),
1907 To allow possible side-effects,
1910 <pre>
1912 </pre><p>
1924 <pre>
1927 </pre><p>
1937 <pre>
1939 </pre><p>
1943 after its initialization;
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,
1964 except that its value is <em>closed</em> whenever the variable
1966 exiting its block by <b>break</b>/<b>goto</b>/<b>return</b>,
1972 to call its <code>__close</code> metamethod.
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,
2007 it does not unwind its stack,
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>,
2014 then its corresponding function will close the coroutine
2030 <pre>
2041 </pre>
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.
2109 resulting in the floor of the division of its operands.
2136 All bitwise operations convert its operands to integers
2209 following its syntax and the rules of the Lua lexer.
2224 non-specified human-readable format.
2226 use the function <a href="#pdf-string.format"><code>string.format</code></a>.
2247 Equality (<code>==</code>) first compares the type of its operands.
2318 The conjunction operator <b>and</b> returns its first argument
2320 otherwise, <b>and</b> returns its second argument.
2321 The disjunction operator <b>or</b> returns its first argument
2323 otherwise, <b>or</b> returns its second argument.
2324 Both <b>and</b> and <b>or</b> use short-circuit evaluation;
2329 <pre>
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
2338 </pre>
2348 in a non-specified format (see <a href="#3.4.3">§3.4.3</a>).
2362 The length of a string is its number of bytes.
2370 A <em>border</em> in a table <code>t</code> is any non-negative integer
2373 <pre>
2376 </pre><p>
2402 <code>#t</code> returns its only border,
2405 <code>#t</code> can return any of its borders.
2409 the memory addresses of its non-numeric keys.)
2430 <pre>
2439 + -
2441 unary operators (not # - ~)
2443 </pre><p>
2458 or to create a table and initialize some of its fields.
2461 <pre>
2466 </pre>
2479 <pre>
2481 </pre><p>
2484 <pre>
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
2496 </pre>
2512 as a convenience for machine-generated code.
2521 <pre>
2523 </pre><p>
2531 its first argument is the value of prefixexp,
2539 <pre>
2541 </pre><p>
2551 <pre>
2555 </pre><p>
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.
2585 <pre>
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
2591 </pre>
2601 <pre>
2604 </pre>
2609 <pre>
2613 </pre><p>
2616 <pre>
2618 </pre><p>
2621 <pre>
2623 </pre><p>
2626 <pre>
2628 </pre><p>
2631 <pre>
2633 </pre><p>
2636 <pre>
2638 </pre><p>
2641 <pre>
2643 </pre><p>
2646 <pre>
2648 </pre><p>
2657 all its function bodies are precompiled too,
2669 <pre>
2671 </pre><p>
2673 it adjusts its list of arguments to
2674 the length of its list of parameters (see <a href="#3.4.12">§3.4.12</a>),
2677 at the end of its parameter list.
2678 A variadic function does not adjust its argument list;
2689 <pre>
2693 </pre><p>
2697 <pre>
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
2710 </pre>
2721 There is a system-dependent limit on the number of values
2732 <pre>
2734 </pre><p>
2737 <pre>
2739 </pre>
2789 the number of parameters in a call to a non-variadic function
2823 in its place.
2829 "the n-th result" and there is no such result,
2832 <pre>
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.
2855 </pre>
2868 its declaration and lasts until the last non-void statement
2873 <pre>
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)
2886 </pre>
2908 <pre>
2915 </pre><p>
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.
2965 The type <a href="#lua_State"><code>lua_State</code></a> (despite its name) refers to a thread.
2998 Lua values and must push its results
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>)
3098 For instance, a C function can query its third argument
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
3186 of its corresponding upvalues.
3198 The registry table is always accessible at pseudo-index
3199 <a name="pdf-LUA_REGISTRYINDEX"><code>LUA_REGISTRYINDEX</code></a>.
3222 its registry comes with some predefined values.
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…
3282 as its name implies,
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;
3351 because the <code>longjmp</code> removes its frame from the C stack.
3381 because its frame in the C stack was destroyed by the yield.
3392 <pre>
3398 </pre><p>
3403 <pre>
3412 </pre><p>
3424 <pre>
3429 </pre><p>
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.
3470 after a <a href="#lua_callk"><code>lua_callk</code></a> the function and its arguments are
3486 <span class="apii">[-o, +p, <em>x</em>]</span>
3494 (Any function always pushes its results after popping its arguments.)
3500 by looking only at its arguments.
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>
3515 <pre>int lua_absindex (lua_State *L, int idx);</pre>
3527 <pre>typedef void * (*lua_Alloc) (void *ud,
3530 size_t nsize);</pre>
3533 The type of the memory-allocation function used by Lua states.
3537 Its arguments are
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…
3583 <pre>
3594 </pre><p>
3604 <span class="apii">[-(2|1), +1, <em>e</em>]</span>
3605 <pre>void lua_arith (lua_State *L, int op);</pre>
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>
3644 <pre>lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
3654 <span class="apii">[-(nargs+1), +nresults, <em>e</em>]</span>
3655 <pre>void lua_call (lua_State *L, int nargs, int nresults);</pre>
3677 unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
3695 <pre>
3697 </pre><p>
3700 <pre>
3704 lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */
3705 lua_remove(L, -2); /* remove 't' from the stack */
3709 </pre><p>
3711 at its end, the stack is back to its original configuration.
3719 <span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
3720 <pre>void lua_callk (lua_State *L,
3724 lua_KFunction k);</pre>
3735 <pre>typedef int (*lua_CFunction) (lua_State *L);</pre>
3745 a C function receives its arguments from Lua in its stack
3750 and its last argument is at index <code>lua_gettop(L)</code>.
3764 <pre>
3780 </pre>
3786 <span class="apii">[-0, +0, –]</span>
3787 <pre>int lua_checkstack (lua_State *L, int n);</pre>
3806 <span class="apii">[-0, +0, –]</span>
3807 <pre>void lua_close (lua_State *L);</pre>
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>
3829 <pre>void lua_closeslot (lua_State *L, int index);</pre>
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>
3851 <pre>int lua_closethread (lua_State *L, lua_State *from);</pre>
3854 Resets a thread, cleaning its call stack and closing all pending
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>
3880 <pre>int lua_compare (lua_State *L, int index1, int index2, int op);</pre>
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>
3908 <pre>void lua_concat (lua_State *L, int n);</pre>
3924 <span class="apii">[-0, +0, –]</span>
3925 <pre>void lua_copy (lua_State *L, int fromidx, int toidx);</pre>
3938 <span class="apii">[-0, +1, <em>m</em>]</span>
3939 <pre>void lua_createtable (lua_State *L, int narr, int nrec);</pre>
3957 <span class="apii">[-0, +0, –]</span>
3958 <pre>int lua_dump (lua_State *L,
3961 int strip);</pre>
3996 <span class="apii">[-1, +0, <em>v</em>]</span>
3997 <pre>int lua_error (lua_State *L);</pre>
4011 <span class="apii">[-0, +0, –]</span>
4012 <pre>int lua_gc (lua_State *L, int what, ...);</pre>
4027 Performs a full garbage-collection cycle.
4071 see <a href="#pdf-collectgarbage"><code>collectgarbage</code></a>.
4082 <span class="apii">[-0, +0, –]</span>
4083 <pre>lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
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>
4096 <pre>int lua_getfield (lua_State *L, int index, const char *k);</pre>
4113 <span class="apii">[-0, +0, –]</span>
4114 <pre>void *lua_getextraspace (lua_State *L);</pre>
4138 <span class="apii">[-0, +1, <em>e</em>]</span>
4139 <pre>int lua_getglobal (lua_State *L, const char *name);</pre>
4150 <span class="apii">[-0, +1, <em>e</em>]</span>
4151 <pre>int lua_geti (lua_State *L, int index, lua_Integer i);</pre>
4168 <span class="apii">[-0, +(0|1), –]</span>
4169 <pre>int lua_getmetatable (lua_State *L, int index);</pre>
4182 <span class="apii">[-1, +1, <em>e</em>]</span>
4183 <pre>int lua_gettable (lua_State *L, int index);</pre>
4193 pushing the resulting value in its place.
4206 <span class="apii">[-0, +0, –]</span>
4207 <pre>int lua_gettop (lua_State *L);</pre>
4220 <span class="apii">[-0, +1, –]</span>
4221 <pre>int lua_getiuservalue (lua_State *L, int index, int n);</pre>
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>
4239 <pre>void lua_insert (lua_State *L, int index);</pre>
4244 This function cannot be called with a pseudo-index,
4245 because a pseudo-index is not an actual stack position.
4252 <pre>typedef ... lua_Integer;</pre>
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>
4277 <pre>int lua_isboolean (lua_State *L, int index);</pre>
4288 <span class="apii">[-0, +0, –]</span>
4289 <pre>int lua_iscfunction (lua_State *L, int index);</pre>
4300 <span class="apii">[-0, +0, –]</span>
4301 <pre>int lua_isfunction (lua_State *L, int index);</pre>
4312 <span class="apii">[-0, +0, –]</span>
4313 <pre>int lua_isinteger (lua_State *L, int index);</pre>
4325 <span class="apii">[-0, +0, –]</span>
4326 <pre>int lua_islightuserdata (lua_State *L, int index);</pre>
4337 <span class="apii">[-0, +0, –]</span>
4338 <pre>int lua_isnil (lua_State *L, int index);</pre>
4349 <span class="apii">[-0, +0, –]</span>
4350 <pre>int lua_isnone (lua_State *L, int index);</pre>
4361 <span class="apii">[-0, +0, –]</span>
4362 <pre>int lua_isnoneornil (lua_State *L, int index);</pre>
4374 <span class="apii">[-0, +0, –]</span>
4375 <pre>int lua_isnumber (lua_State *L, int index);</pre>
4387 <span class="apii">[-0, +0, –]</span>
4388 <pre>int lua_isstring (lua_State *L, int index);</pre>
4400 <span class="apii">[-0, +0, –]</span>
4401 <pre>int lua_istable (lua_State *L, int index);</pre>
4412 <span class="apii">[-0, +0, –]</span>
4413 <pre>int lua_isthread (lua_State *L, int index);</pre>
4424 <span class="apii">[-0, +0, –]</span>
4425 <pre>int lua_isuserdata (lua_State *L, int index);</pre>
4436 <span class="apii">[-0, +0, –]</span>
4437 <pre>int lua_isyieldable (lua_State *L);</pre>
4448 <pre>typedef ... lua_KContext;</pre>
4451 The type for continuation-function contexts.
4463 <pre>typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);</pre>
4473 <span class="apii">[-0, +1, <em>e</em>]</span>
4474 <pre>void lua_len (lua_State *L, int index);</pre>
4487 <span class="apii">[-0, +1, –]</span>
4488 <pre>int lua_load (lua_State *L,
4492 const char *mode);</pre>
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…
4536 its first upvalue is set to the value of the global environment
4547 <span class="apii">[-0, +0, –]</span>
4548 <pre>lua_State *lua_newstate (lua_Alloc f, void *ud);</pre>
4551 Creates a new independent state and returns its main thread.
4565 <span class="apii">[-0, +1, <em>m</em>]</span>
4566 <pre>void lua_newtable (lua_State *L);</pre>
4577 <span class="apii">[-0, +1, <em>m</em>]</span>
4578 <pre>lua_State *lua_newthread (lua_State *L);</pre>
4584 its global environment,
4597 <span class="apii">[-0, +1, <em>m</em>]</span>
4598 <pre>void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue);</pre>
4613 its address is valid at least until the call to its finalizer.
4620 <span class="apii">[-1, +(2|0), <em>v</em>]</span>
4621 <pre>int lua_next (lua_State *L, int index);</pre>
4634 <pre>
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)));
4645 </pre>
4659 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
4660 the table during its traversal.
4667 <pre>typedef ... lua_Number;</pre>
4683 <pre>int lua_numbertointeger (lua_Number n, lua_Integer *p);</pre>
4697 This macro may evaluate its arguments more than once.
4704 <span class="apii">[-(nargs + 1), +(nresults|1), –]</span>
4705 <pre>int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);</pre>
4722 and its arguments from the stack.
4731 (This index cannot be a pseudo-index.)
4734 and its return value will be the object
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>
4755 <pre>int lua_pcallk (lua_State *L,
4760 lua_KFunction k);</pre>
4771 <span class="apii">[-n, +0, <em>e</em>]</span>
4772 <pre>void lua_pop (lua_State *L, int n);</pre>
4783 <span class="apii">[-0, +1, –]</span>
4784 <pre>void lua_pushboolean (lua_State *L, int b);</pre>
4794 <span class="apii">[-n, +1, <em>m</em>]</span>
4795 <pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
4808 follow the correct protocol to receive its parameters
4809 and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
4819 first the initial values for its upvalues must be pushed onto the stack.
4843 <span class="apii">[-0, +1, –]</span>
4844 <pre>void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
4855 <span class="apii">[-0, +1, <em>v</em>]</span>
4856 <pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
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>
4891 <pre>void lua_pushglobaltable (lua_State *L);</pre>
4901 <span class="apii">[-0, +1, –]</span>
4902 <pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
4912 <span class="apii">[-0, +1, –]</span>
4913 <pre>void lua_pushlightuserdata (lua_State *L, void *p);</pre>
4933 <span class="apii">[-0, +1, <em>m</em>]</span>
4934 <pre>const char *lua_pushliteral (lua_State *L, const char *s);</pre>
4946 <span class="apii">[-0, +1, <em>m</em>]</span>
4947 <pre>const char *lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
4967 <span class="apii">[-0, +1, –]</span>
4968 <pre>void lua_pushnil (lua_State *L);</pre>
4978 <span class="apii">[-0, +1, –]</span>
4979 <pre>void lua_pushnumber (lua_State *L, lua_Number n);</pre>
4989 <span class="apii">[-0, +1, <em>m</em>]</span>
4990 <pre>const char *lua_pushstring (lua_State *L, const char *s);</pre>
4993 Pushes the zero-terminated string pointed to by <code>s</code>
5012 <span class="apii">[-0, +1, –]</span>
5013 <pre>int lua_pushthread (lua_State *L);</pre>
5017 Returns 1 if this thread is the main thread of its state.
5024 <span class="apii">[-0, +1, –]</span>
5025 <pre>void lua_pushvalue (lua_State *L, int index);</pre>
5036 <span class="apii">[-0, +1, <em>v</em>]</span>
5037 <pre>const char *lua_pushvfstring (lua_State *L,
5039 va_list argp);</pre>
5050 <span class="apii">[-0, +0, –]</span>
5051 <pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
5065 <span class="apii">[-1, +1, –]</span>
5066 <pre>int lua_rawget (lua_State *L, int index);</pre>
5078 <span class="apii">[-0, +1, –]</span>
5079 <pre>int lua_rawgeti (lua_State *L, int index, lua_Integer n);</pre>
5096 <span class="apii">[-0, +1, –]</span>
5097 <pre>int lua_rawgetp (lua_State *L, int index, const void *p);</pre>
5115 <span class="apii">[-0, +0, –]</span>
5116 <pre>lua_Unsigned lua_rawlen (lua_State *L, int index);</pre>
5132 <span class="apii">[-2, +0, <em>m</em>]</span>
5133 <pre>void lua_rawset (lua_State *L, int index);</pre>
5145 <span class="apii">[-1, +0, <em>m</em>]</span>
5146 <pre>void lua_rawseti (lua_State *L, int index, lua_Integer i);</pre>
5164 <span class="apii">[-1, +0, <em>m</em>]</span>
5165 <pre>void lua_rawsetp (lua_State *L, int index, const void *p);</pre>
5184 <pre>typedef const char * (*lua_Reader) (lua_State *L,
5186 size_t *size);</pre>
5192 passing along its <code>data</code> parameter.
5206 <span class="apii">[-0, +0, <em>e</em>]</span>
5207 <pre>void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
5213 <pre>
5216 </pre>
5222 <span class="apii">[-1, +0, –]</span>
5223 <pre>void lua_remove (lua_State *L, int index);</pre>
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>
5237 <pre>void lua_replace (lua_State *L, int index);</pre>
5250 <span class="apii">[-0, +?, –]</span>
5251 <pre>int lua_resetthread (lua_State *L);</pre>
5263 <span class="apii">[-?, +?, –]</span>
5264 <pre>int lua_resume (lua_State *L, lua_State *from, int nargs,
5265 int *nresults);</pre>
5277 This call returns when the coroutine suspends or finishes its execution.
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
5294 you remove the <code>*nresults</code> yielded values from its stack,
5309 <span class="apii">[-0, +0, –]</span>
5310 <pre>void lua_rotate (lua_State *L, int idx, int n);</pre>
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>
5330 <pre>void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
5341 <span class="apii">[-1, +0, <em>e</em>]</span>
5342 <pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
5360 <span class="apii">[-1, +0, <em>e</em>]</span>
5361 <pre>void lua_setglobal (lua_State *L, const char *name);</pre>
5372 <span class="apii">[-1, +0, <em>e</em>]</span>
5373 <pre>void lua_seti (lua_State *L, int index, lua_Integer n);</pre>
5391 <span class="apii">[-1, +0, –]</span>
5392 <pre>int lua_setiuservalue (lua_State *L, int index, int n);</pre>
5396 the new <code>n</code>-th user value associated to the
5405 <span class="apii">[-1, +0, –]</span>
5406 <pre>int lua_setmetatable (lua_State *L, int index);</pre>
5423 <span class="apii">[-2, +0, <em>e</em>]</span>
5424 <pre>void lua_settable (lua_State *L, int index);</pre>
5443 <span class="apii">[-?, +?, <em>e</em>]</span>
5444 <pre>void lua_settop (lua_State *L, int index);</pre>
5456 marked as to-be-closed from the stack.
5463 <span class="apii">[-0, +0, –]</span>
5464 <pre>void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);</pre>
5477 <pre>typedef struct lua_State lua_State;</pre>
5497 <span class="apii">[-0, +0, –]</span>
5498 <pre>int lua_status (lua_State *L);</pre>
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>
5523 <pre>size_t lua_stringtonumber (lua_State *L, const char *s);</pre>
5526 Converts the zero-terminated string <code>s</code> to a number,
5529 that is, its length plus one.
5543 <span class="apii">[-0, +0, –]</span>
5544 <pre>int lua_toboolean (lua_State *L, int index);</pre>
5561 <span class="apii">[-0, +0, –]</span>
5562 <pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
5574 <span class="apii">[-0, +0, <em>m</em>]</span>
5575 <pre>void lua_toclose (lua_State *L, int index);</pre>
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>
5612 <pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
5622 <span class="apii">[-0, +0, –]</span>
5623 <pre>lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);</pre>
5635 its referent is assigned a boolean value that
5643 <span class="apii">[-0, +0, <em>m</em>]</span>
5644 <pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
5663 after its last character (as in C),
5664 but can contain other zeros in its body.
5671 <span class="apii">[-0, +0, –]</span>
5672 <pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
5682 <span class="apii">[-0, +0, –]</span>
5683 <pre>lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);</pre>
5695 its referent is assigned a boolean value that
5703 <span class="apii">[-0, +0, –]</span>
5704 <pre>const void *lua_topointer (lua_State *L, int index);</pre>
5712 There is no way to convert the pointer back to its original value.
5723 <span class="apii">[-0, +0, <em>m</em>]</span>
5724 <pre>const char *lua_tostring (lua_State *L, int index);</pre>
5734 <span class="apii">[-0, +0, –]</span>
5735 <pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
5748 <span class="apii">[-0, +0, –]</span>
5749 <pre>void *lua_touserdata (lua_State *L, int index);</pre>
5753 returns its memory-block address.
5755 returns its value (a pointer).
5763 <span class="apii">[-0, +0, –]</span>
5764 <pre>int lua_type (lua_State *L, int index);</pre>
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>
5799 <pre>typedef ... lua_Unsigned;</pre>
5809 <span class="apii">[-0, +0, –]</span>
5810 <pre>int lua_upvalueindex (int i);</pre>
5813 Returns the pseudo-index that represents the <code>i</code>-th upvalue of
5822 <span class="apii">[-0, +0, –]</span>
5823 <pre>lua_Number lua_version (lua_State *L);</pre>
5833 <pre>typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);</pre>
5846 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5853 <span class="apii">[-0, +0, –]</span>
5854 <pre>void lua_warning (lua_State *L, const char *msg, int tocont);</pre>
5863 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5870 <pre>typedef int (*lua_Writer) (lua_State *L,
5873 void* ud);</pre>
5880 its size (<code>sz</code>),
5895 <span class="apii">[-?, +?, –]</span>
5896 <pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
5911 <span class="apii">[-?, +?, <em>v</em>]</span>
5912 <pre>int lua_yield (lua_State *L, int nresults);</pre>
5928 <span class="apii">[-?, +?, <em>v</em>]</span>
5929 <pre>int lua_yieldk (lua_State *L,
5932 lua_KFunction k);</pre>
5940 the running coroutine suspends its execution,
5978 (what is called a <em>C-call boundary</em>),
5991 Lua has no built-in debugging facilities.
6001 <pre>typedef struct lua_Debug {
6020 } lua_Debug;</pre>
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>
6144 <pre>lua_Hook lua_gethook (lua_State *L);</pre>
6154 <span class="apii">[-0, +0, –]</span>
6155 <pre>int lua_gethookcount (lua_State *L);</pre>
6165 <span class="apii">[-0, +0, –]</span>
6166 <pre>int lua_gethookmask (lua_State *L);</pre>
6176 <span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
6177 <pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
6198 <pre>
6203 </pre>
6247 its table is pushed after the function.
6262 <span class="apii">[-0, +(0|1), –]</span>
6263 <pre>const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
6276 see <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for details about variable indices
6282 and returns its name.
6303 <span class="apii">[-0, +0, –]</span>
6304 <pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
6326 <span class="apii">[-0, +(0|1), –]</span>
6327 <pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
6330 Gets information about the <code>n</code>-th upvalue
6333 and returns its name.
6339 See <a href="#pdf-debug.getupvalue"><code>debug.getupvalue</code></a> for more information about up…
6346 <pre>typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);</pre>
6353 Whenever a hook is called, its <code>ar</code> argument has its field
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>.
6385 to yield, a hook function must finish its execution
6394 <span class="apii">[-0, +0, –]</span>
6395 <pre>void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
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>
6445 <pre>const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
6450 to the variable and returns its name.
6468 <span class="apii">[-(0|1), +0, –]</span>
6469 <pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
6474 to the upvalue and returns its name.
6492 <span class="apii">[-0, +0, –]</span>
6493 <pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
6518 <span class="apii">[-0, +0, –]</span>
6519 <pre>void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
6520 int funcindex2, int n2);</pre>
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>
6594 <pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
6605 <span class="apii">[-?, +?, <em>m</em>]</span>
6606 <pre>const void luaL_addgsub (luaL_Buffer *B, const char *s,
6607 const char *p, const char *r);</pre>
6619 <span class="apii">[-?, +?, <em>m</em>]</span>
6620 <pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
6633 <span class="apii">[-?, +?, –]</span>
6634 <pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
6646 <span class="apii">[-?, +?, <em>m</em>]</span>
6647 <pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
6650 Adds the zero-terminated string pointed to by <code>s</code>
6659 <span class="apii">[-?, +?, <em>m</em>]</span>
6660 <pre>void luaL_addvalue (luaL_Buffer *B);</pre>
6679 <span class="apii">[-0, +0, <em>v</em>]</span>
6680 <pre>void luaL_argcheck (lua_State *L,
6683 const char *extramsg);</pre>
6694 <span class="apii">[-0, +0, <em>v</em>]</span>
6695 <pre>int luaL_argerror (lua_State *L, int arg, const char *extramsg);</pre>
6703 <pre>
6705 </pre><p>
6713 <span class="apii">[-0, +0, <em>v</em>]</span>
6714 <pre>void luaL_argexpected (lua_State *L,
6717 const char *tname);</pre>
6729 <pre>typedef struct luaL_Buffer luaL_Buffer;</pre>
6737 Its pattern of use is as follows:
6780 During its normal operation,
6792 the stack is back to its level when the buffer was initialized,
6793 plus the final string on its top.
6800 <span class="apii">[-0, +0, –]</span>
6801 <pre>char *luaL_buffaddr (luaL_Buffer *B);</pre>
6813 <span class="apii">[-0, +?, –]</span>
6814 <pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
6827 <span class="apii">[-0, +0, –]</span>
6828 <pre>size_t luaL_bufflen (luaL_Buffer *B);</pre>
6839 <span class="apii">[-?, +?, <em>m</em>]</span>
6840 <pre>char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
6851 <span class="apii">[-?, +?, –]</span>
6852 <pre>void luaL_buffsub (luaL_Buffer *B, int n);</pre>
6864 <span class="apii">[-0, +(0|1), <em>e</em>]</span>
6865 <pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
6874 this function calls this field passing the object as its only argument.
6885 <span class="apii">[-0, +0, <em>v</em>]</span>
6886 <pre>void luaL_checkany (lua_State *L, int arg);</pre>
6897 <span class="apii">[-0, +0, <em>v</em>]</span>
6898 <pre>lua_Integer luaL_checkinteger (lua_State *L, int arg);</pre>
6910 <span class="apii">[-0, +0, <em>v</em>]</span>
6911 <pre>const char *luaL_checklstring (lua_State *L, int arg, size_t *l);</pre>
6916 if <code>l</code> is not <code>NULL</code> fills its referent
6921 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
6929 <span class="apii">[-0, +0, <em>v</em>]</span>
6930 <pre>lua_Number luaL_checknumber (lua_State *L, int arg);</pre>
6941 <span class="apii">[-0, +0, <em>v</em>]</span>
6942 <pre>int luaL_checkoption (lua_State *L,
6945 const char *const lst[]);</pre>
6950 (which must be NULL-terminated).
6972 <span class="apii">[-0, +0, <em>v</em>]</span>
6973 <pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
6986 <span class="apii">[-0, +0, <em>v</em>]</span>
6987 <pre>const char *luaL_checkstring (lua_State *L, int arg);</pre>
6995 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
7003 <span class="apii">[-0, +0, <em>v</em>]</span>
7004 <pre>void luaL_checktype (lua_State *L, int arg, int t);</pre>
7015 <span class="apii">[-0, +0, <em>v</em>]</span>
7016 <pre>void *luaL_checkudata (lua_State *L, int arg, const char *tname);</pre>
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>
7029 <pre>void luaL_checkversion (lua_State *L);</pre>
7040 <span class="apii">[-0, +?, <em>m</em>]</span>
7041 <pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
7047 <pre>
7049 </pre><p>
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>
7059 <pre>int luaL_dostring (lua_State *L, const char *str);</pre>
7065 <pre>
7067 </pre><p>
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>
7077 <pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
7099 <span class="apii">[-0, +3, <em>m</em>]</span>
7100 <pre>int luaL_execresult (lua_State *L, int stat);</pre>
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>
7113 <pre>int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre>
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>
7126 <pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
7140 <span class="apii">[-0, +1, <em>m</em>]</span>
7141 <pre>int luaL_getmetatable (lua_State *L, const char *tname);</pre>
7154 <span class="apii">[-0, +1, <em>e</em>]</span>
7155 <pre>int luaL_getsubtable (lua_State *L, int idx, const char *fname);</pre>
7170 <span class="apii">[-0, +1, <em>m</em>]</span>
7171 <pre>const char *luaL_gsub (lua_State *L,
7174 const char *r);</pre>
7187 <span class="apii">[-0, +0, <em>e</em>]</span>
7188 <pre>lua_Integer luaL_len (lua_State *L, int index);</pre>
7202 <span class="apii">[-0, +1, –]</span>
7203 <pre>int luaL_loadbuffer (lua_State *L,
7206 const char *name);</pre>
7216 <span class="apii">[-0, +1, –]</span>
7217 <pre>int luaL_loadbufferx (lua_State *L,
7221 const char *mode);</pre>
7240 <span class="apii">[-0, +1, <em>m</em>]</span>
7241 <pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
7251 <span class="apii">[-0, +1, <em>m</em>]</span>
7252 <pre>int luaL_loadfilex (lua_State *L, const char *filename,
7253 const char *mode);</pre>
7270 or <a href="#pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a> for file-related errors.
7282 <span class="apii">[-0, +1, –]</span>
7283 <pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
7288 the zero-terminated string <code>s</code>.
7304 <span class="apii">[-0, +1, <em>m</em>]</span>
7305 <pre>void luaL_newlib (lua_State *L, const luaL_Reg l[]);</pre>
7315 <pre>
7317 </pre><p>
7326 <span class="apii">[-0, +1, <em>m</em>]</span>
7327 <pre>void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);</pre>
7347 <span class="apii">[-0, +1, <em>m</em>]</span>
7348 <pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
7370 <span class="apii">[-0, +0, –]</span>
7371 <pre>lua_State *luaL_newstate (void);</pre>
7390 <span class="apii">[-0, +0, <em>e</em>]</span>
7391 <pre>void luaL_openlibs (lua_State *L);</pre>
7401 <span class="apii">[-0, +0, –]</span>
7402 <pre>T luaL_opt (L, func, arg, dflt);</pre>
7407 <pre>
7409 </pre><p>
7422 <span class="apii">[-0, +0, <em>v</em>]</span>
7423 <pre>lua_Integer luaL_optinteger (lua_State *L,
7425 lua_Integer d);</pre>
7440 <span class="apii">[-0, +0, <em>v</em>]</span>
7441 <pre>const char *luaL_optlstring (lua_State *L,
7444 size_t *l);</pre>
7456 fills its referent with the result's length.
7459 its length is considered zero.
7463 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
7471 <span class="apii">[-0, +0, <em>v</em>]</span>
7472 <pre>lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);</pre>
7486 <span class="apii">[-0, +0, <em>v</em>]</span>
7487 <pre>const char *luaL_optstring (lua_State *L,
7489 const char *d);</pre>
7503 <span class="apii">[-?, +?, <em>m</em>]</span>
7504 <pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
7508 with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
7515 <span class="apii">[-?, +?, <em>m</em>]</span>
7516 <pre>char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
7531 <span class="apii">[-0, +1, –]</span>
7532 <pre>void luaL_pushfail (lua_State *L);</pre>
7542 <span class="apii">[-?, +1, <em>m</em>]</span>
7543 <pre>void luaL_pushresult (luaL_Buffer *B);</pre>
7554 <span class="apii">[-?, +1, <em>m</em>]</span>
7555 <pre>void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
7565 <span class="apii">[-1, +0, <em>m</em>]</span>
7566 <pre>int luaL_ref (lua_State *L, int t);</pre>
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
7594 <pre>typedef struct luaL_Reg {
7597 } luaL_Reg;</pre>
7612 <span class="apii">[-0, +1, <em>e</em>]</span>
7613 <pre>void luaL_requiref (lua_State *L, const char *modname,
7614 lua_CFunction openf, int glb);</pre>
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>
7637 <pre>void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
7663 <span class="apii">[-0, +0, –]</span>
7664 <pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>
7676 <pre>typedef struct luaL_Stream {
7679 } luaL_Stream;</pre>
7702 this function receives the file handle as its sole argument and
7714 <span class="apii">[-0, +0, <em>m</em>]</span>
7715 <pre>void *luaL_testudata (lua_State *L, int arg, const char *tname);</pre>
7727 <span class="apii">[-0, +1, <em>e</em>]</span>
7728 <pre>const char *luaL_tolstring (lua_State *L, int idx, size_t *len);</pre>
7743 and uses the result of the call as its result.
7750 <span class="apii">[-0, +1, <em>m</em>]</span>
7751 <pre>void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
7752 int level);</pre>
7766 <span class="apii">[-0, +0, <em>v</em>]</span>
7767 <pre>int luaL_typeerror (lua_State *L, int arg, const char *tname);</pre>
7781 <span class="apii">[-0, +0, –]</span>
7782 <pre>const char *luaL_typename (lua_State *L, int index);</pre>
7792 <span class="apii">[-0, +0, –]</span>
7793 <pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
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>
7813 <pre>void luaL_where (lua_State *L, int lvl);</pre>
7820 <pre>
7822 </pre><p>
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
7857 to its expected parameters.
7884 <li>basic UTF-8 support (<a href="#6.5">§6.5</a>);</li>
7898 each library provides all its functions as fields of a global table
7899 or as methods of its objects.
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>.
7931 implementations for some of its facilities.
7935 <hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
7940 the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
7941 otherwise, returns all its arguments.
7950 <hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>
7955 It performs different functions according to its first argument, <code>opt</code>:
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>
8027 Opens the named file and executes its content as a Lua chunk.
8032 to its caller.
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>
8063 changing its value does not affect any environment,
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>
8091 <pre>
8093 </pre><p>
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…
8131 and there is no guarantee that its first upvalue will be
8133 (A non-main function may not even have an <code>_ENV</code> upvalue.)
8138 its first upvalue is set to the value of <code>env</code>,
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>
8192 Its first argument is a table and its second argument
8195 and its associated value.
8196 When called with <b>nil</b> as its second argument,
8198 and its associated value.
8215 You should not assign any value to a non-existent field in a table
8216 during its traversal.
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…
8238 <pre>
8240 </pre><p>
8245 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
8246 the table during its traversal.
8252 <hr><h3><a name="pdf-pcall"><code>pcall (f [, arg1, ···])</code></a></h3>
8261 Its first result is the status code (a boolean),
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>
8376 <code>tonumber</code> tries to convert its argument to a number.
8404 <hr><h3><a name="pdf-tostring"><code>tostring (v)</code></a></h3>
8409 converts it to a string in a human-readable format.
8416 and uses the result of the call as its result.
8419 <code>tostring</code> may use that string in its final result.
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>
8434 Returns the type of its only argument, coded as a string.
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>
8466 of all its arguments (which should be strings).
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, ···…
8560 it starts running its body.
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>
8604 and <code>"dead"</code> if the coroutine has finished its body function,
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…
8934 <pre>
8936 </pre><p>
8949 its suffix after (and including) the first hyphen is removed.
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>.
8965 with each submodule keeping its original open function.
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…
9007 <pre>
9009 </pre><p>
9039 Thus, the last character is at position -1, and so on.
9043 The string library provides all its functions inside the table
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>
9077 to its corresponding argument.
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>
9127 its default value is 1 and can be negative.
9144 <hr><h3><a name="pdf-string.format"><code>string.format (formatstring, ···)</c…
9148 Returns a formatted version of its variable number of arguments
9149 following the description given in its first argument,
9171 <pre>
9173 </pre><p>
9176 <pre>
9179 </pre><p>
9197 if its argument is not a string,
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>
9225 its default value is 1 and can be negative.
9233 <pre>
9238 </pre><p>
9242 <pre>
9248 </pre>
9258 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
9264 <code>gsub</code> also returns, as its second value,
9270 If <code>repl</code> is a string, then its value is used for replacement.
9274 stands for the value of the <em>d</em>-th captured substring;
9308 <pre>
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"
9329 </pre>
9334 <hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
9338 Receives a string and returns its length.
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>
9373 its default value is 1 and can be negative.
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…
9718 <pre>
9720 --> 1 2
9721 --> 3 3
9722 --> 4 4
9723 </pre><p>
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>
9772 <li><b><code>s[<em>n</em>]</code>: </b>a string preceded by its length
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.
9820 option "<code>s</code>" follows the alignment of its starting integer.
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>.
9841 such as character classification, is outside its scope.
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>
9904 <pre>
9906 </pre><p>
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.
9956 nor right after its end,
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>
10115 <pre>
10117 </pre><p>
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>
10317 Its second result is always a float.
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>
10552 and sets its handle as the default input file.
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>
10745 <pre>
10747 </pre><p>
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>
10850 end of the file, and returns its size.
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>
10888 Writes the value of each of its arguments to <code>file</code>.
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,
10966 because of its reliance on C function <code>gmtime</code> and C function <code>localtime<…
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>
10992 Its first result is <b>true</b>
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.
11110 because of its reliance on C function <code>setlocale</code>.
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>
11168 The file must be explicitly opened before its use
11184 you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
11199 Several of its functions
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>
11229 so that the caller continues its execution.
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>
11374 and that are consequently included in its closure.)
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.
11429 When the hook is called, its first parameter is a string
11430 describing the event that has triggered its call:
11434 the hook also gets the new line number as its second parameter.
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>.
11575 Its usage is:
11577 <pre>
11579 </pre><p>
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.)
11599 After handling its options, <code>lua</code> runs the given <em>script</em>.
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
11629 <pre>
11630 $ lua -e 'a=1' -llib1 script.lua
11631 </pre><p>
11639 <code>lua</code> collects all command-line arguments
11645 (that is, the interpreter name plus its options)
11649 <pre>
11650 $ lua -la b.lua t1 t2
11651 </pre><p>
11654 <pre>
11655 arg = { [-2] = "lua", [-1] = "-la",
11658 </pre><p>
11664 <pre>
11665 $ lua -e "print(arg[1])"
11666 </pre><p>
11667 will print "<code>-e</code>".
11680 If it succeeds, it prints its value.
11683 the interpreter waits for its completion
11688 If the global variable <a name="pdf-_PROMPT"><code>_PROMPT</code></a> contains a string,
11689 then its value is used as the prompt.
11690 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a strin…
11691 its value is used as the secondary prompt
11709 the interpreter closes its main Lua state
11712 calling <a href="#pdf-os.exit"><code>os.exit</code></a> to terminate.
11723 <pre>
11725 </pre><p>
11731 <pre>
11733 </pre><p>
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…
11848 to format its arguments;
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.
11957 <pre>
12020 …binop ::= ‘<b>+</b>’ | ‘<b>-</b>’ | ‘<b>*</b>’ | ‘<b>/<…
12025 unop ::= ‘<b>-</b>’ | <b>not</b> | ‘<b>#</b>’ | ‘<b>~</b>’
12027 </pre>
12041 <!--
12043 -->