Lines Matching +full:pre +full:-

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 &copy; 2020&ndash;2025 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 &ndash; <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…
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:
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.
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>
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>
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>
1787 <pre>
1789 </pre><p>
1807 Beware of floating-point accuracy in this case.
1851 <pre>
1854 </pre><p>
1857 <pre>
1859 </pre><p>
1891 to-be-closed variable (see <a href="#3.3.8">&sect;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>
1944 and <code>close</code>, which declares a to-be-closed variable (see <a href="#3.3.8">&sect;3.3.8</a…
1945 A list of variables can contain at most one to-be-closed variable.
1960 <h3>3.3.8 &ndash; <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>,
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.
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;
2329 <pre>
2330 10 or 20 --&gt; 10
2331 10 or error() --&gt; 10
2332 nil or "a" --&gt; "a"
2333 nil and 10 --&gt; nil
2334 false and error() --&gt; false
2335 false and nil --&gt; false
2336 false or nil --&gt; nil
2337 10 and 20 --&gt; 20
2338 </pre>
2348 in a non-specified format (see <a href="#3.4.3">&sect;3.4.3</a>).
2370 A <em>border</em> in a table <code>t</code> is any non-negative integer
2373 <pre>
2376 </pre><p>
2409 the memory addresses of its non-numeric keys.)
2430 <pre>
2439 + -
2441 unary operators (not # - ~)
2443 </pre><p>
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>
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>
2669 <pre>
2671 </pre><p>
2689 <pre>
2693 </pre><p>
2697 <pre>
2706 g(3) a=3, b=nil, ... --&gt; (nothing)
2707 g(3, 4) a=3, b=4, ... --&gt; (nothing)
2708 g(3, 4, 5, 8) a=3, b=4, ... --&gt; 5 8
2709 g(5, r()) a=5, b=1, ... --&gt; 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
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) --&gt; 10
2879 do -- another block
2880 local x = x+1 -- another 'x'
2881 print(x) --&gt; 12
2883 print(x) --&gt; 11
2885 print(x) --&gt; 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.
3015 index&nbsp;-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">&sect;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;
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.
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, &ndash;]</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.
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>&amp;…
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>&lt;&lt;…
3635 <li><b><a name="pdf-LUA_OPSHR"><code>LUA_OPSHR</code></a>: </b> performs right shift (<code>&gt;&gt…
3643 <span class="apii">[-0, +0, &ndash;]</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>
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>
3764 <pre>
3780 </pre>
3786 <span class="apii">[-0, +0, &ndash;]</span>
3787 <pre>int lua_checkstack (lua_State *L, int n);</pre>
3806 <span class="apii">[-0, +0, &ndash;]</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, +?, &ndash;]</span>
3851 <pre>int lua_closethread (lua_State *L, lua_State *from);</pre>
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>&lt;</c…
3899 <li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code>&lt…
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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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), &ndash;]</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>
4206 <span class="apii">[-0, +0, &ndash;]</span>
4207 <pre>int lua_gettop (lua_State *L);</pre>
4220 <span class="apii">[-0, +1, &ndash;]</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, &ndash;]</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, &ndash;]</span>
4277 <pre>int lua_isboolean (lua_State *L, int index);</pre>
4288 <span class="apii">[-0, +0, &ndash;]</span>
4289 <pre>int lua_iscfunction (lua_State *L, int index);</pre>
4300 <span class="apii">[-0, +0, &ndash;]</span>
4301 <pre>int lua_isfunction (lua_State *L, int index);</pre>
4312 <span class="apii">[-0, +0, &ndash;]</span>
4313 <pre>int lua_isinteger (lua_State *L, int index);</pre>
4325 <span class="apii">[-0, +0, &ndash;]</span>
4326 <pre>int lua_islightuserdata (lua_State *L, int index);</pre>
4337 <span class="apii">[-0, +0, &ndash;]</span>
4338 <pre>int lua_isnil (lua_State *L, int index);</pre>
4349 <span class="apii">[-0, +0, &ndash;]</span>
4350 <pre>int lua_isnone (lua_State *L, int index);</pre>
4361 <span class="apii">[-0, +0, &ndash;]</span>
4362 <pre>int lua_isnoneornil (lua_State *L, int index);</pre>
4374 <span class="apii">[-0, +0, &ndash;]</span>
4375 <pre>int lua_isnumber (lua_State *L, int index);</pre>
4387 <span class="apii">[-0, +0, &ndash;]</span>
4388 <pre>int lua_isstring (lua_State *L, int index);</pre>
4400 <span class="apii">[-0, +0, &ndash;]</span>
4401 <pre>int lua_istable (lua_State *L, int index);</pre>
4412 <span class="apii">[-0, +0, &ndash;]</span>
4413 <pre>int lua_isthread (lua_State *L, int index);</pre>
4424 <span class="apii">[-0, +0, &ndash;]</span>
4425 <pre>int lua_isuserdata (lua_State *L, int index);</pre>
4436 <span class="apii">[-0, +0, &ndash;]</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, &ndash;]</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…
4547 <span class="apii">[-0, +0, &ndash;]</span>
4548 <pre>lua_State *lua_newstate (lua_Alloc f, void *ud);</pre>
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>
4597 <span class="apii">[-0, +1, <em>m</em>]</span>
4598 <pre>void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue);</pre>
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
4667 <pre>typedef ... lua_Number;</pre>
4683 <pre>int lua_numbertointeger (lua_Number n, lua_Integer *p);</pre>
4704 <span class="apii">[-(nargs + 1), +(nresults|1), &ndash;]</span>
4705 <pre>int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);</pre>
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), &ndash;]</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, &ndash;]</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>
4843 <span class="apii">[-0, +1, &ndash;]</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, &ndash;]</span>
4891 <pre>void lua_pushglobaltable (lua_State *L);</pre>
4901 <span class="apii">[-0, +1, &ndash;]</span>
4902 <pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
4912 <span class="apii">[-0, +1, &ndash;]</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, &ndash;]</span>
4968 <pre>void lua_pushnil (lua_State *L);</pre>
4978 <span class="apii">[-0, +1, &ndash;]</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, &ndash;]</span>
5013 <pre>int lua_pushthread (lua_State *L);</pre>
5024 <span class="apii">[-0, +1, &ndash;]</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, &ndash;]</span>
5051 <pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
5065 <span class="apii">[-1, +1, &ndash;]</span>
5066 <pre>int lua_rawget (lua_State *L, int index);</pre>
5078 <span class="apii">[-0, +1, &ndash;]</span>
5079 <pre>int lua_rawgeti (lua_State *L, int index, lua_Integer n);</pre>
5096 <span class="apii">[-0, +1, &ndash;]</span>
5097 <pre>int lua_rawgetp (lua_State *L, int index, const void *p);</pre>
5115 <span class="apii">[-0, +0, &ndash;]</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>
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, &ndash;]</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, &ndash;]</span>
5237 <pre>void lua_replace (lua_State *L, int index);</pre>
5250 <span class="apii">[-0, +?, &ndash;]</span>
5251 <pre>int lua_resetthread (lua_State *L);</pre>
5263 <span class="apii">[-?, +?, &ndash;]</span>
5264 <pre>int lua_resume (lua_State *L, lua_State *from, int nargs,
5265 int *nresults);</pre>
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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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, &ndash;]</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,
5543 <span class="apii">[-0, +0, &ndash;]</span>
5544 <pre>int lua_toboolean (lua_State *L, int index);</pre>
5561 <span class="apii">[-0, +0, &ndash;]</span>
5562 <pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
5574 <span class="apii">[-0, +0, <em>v</em>]</span>
5575 <pre>void lua_toclose (lua_State *L, int index);</pre>
5579 to-be-closed slot (see <a href="#3.3.8">&sect;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
5601 that is equal to or below an active to-be-closed slot.
5616 <span class="apii">[-0, +0, &ndash;]</span>
5617 <pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
5627 <span class="apii">[-0, +0, &ndash;]</span>
5628 <pre>lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);</pre>
5648 <span class="apii">[-0, +0, <em>m</em>]</span>
5649 <pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
5682 <span class="apii">[-0, +0, &ndash;]</span>
5683 <pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
5693 <span class="apii">[-0, +0, &ndash;]</span>
5694 <pre>lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);</pre>
5714 <span class="apii">[-0, +0, &ndash;]</span>
5715 <pre>const void *lua_topointer (lua_State *L, int index);</pre>
5734 <span class="apii">[-0, +0, <em>m</em>]</span>
5735 <pre>const char *lua_tostring (lua_State *L, int index);</pre>
5745 <span class="apii">[-0, +0, &ndash;]</span>
5746 <pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
5759 <span class="apii">[-0, +0, &ndash;]</span>
5760 <pre>void *lua_touserdata (lua_State *L, int index);</pre>
5764 returns its memory-block address.
5774 <span class="apii">[-0, +0, &ndash;]</span>
5775 <pre>int lua_type (lua_State *L, int index);</pre>
5779 or <code>LUA_TNONE</code> for a non-valid but acceptable index.
5782 <a name="pdf-LUA_TNIL"><code>LUA_TNIL</code></a>,
5783 <a name="pdf-LUA_TNUMBER"><code>LUA_TNUMBER</code></a>,
5784 <a name="pdf-LUA_TBOOLEAN"><code>LUA_TBOOLEAN</code></a>,
5785 <a name="pdf-LUA_TSTRING"><code>LUA_TSTRING</code></a>,
5786 <a name="pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>,
5787 <a name="pdf-LUA_TFUNCTION"><code>LUA_TFUNCTION</code></a>,
5788 <a name="pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>,
5789 <a name="pdf-LUA_TTHREAD"><code>LUA_TTHREAD</code></a>,
5791 <a name="pdf-LUA_TLIGHTUSERDATA"><code>LUA_TLIGHTUSERDATA</code></a>.
5798 <span class="apii">[-0, +0, &ndash;]</span>
5799 <pre>const char *lua_typename (lua_State *L, int tp);</pre>
5810 <pre>typedef ... lua_Unsigned;</pre>
5820 <span class="apii">[-0, +0, &ndash;]</span>
5821 <pre>int lua_upvalueindex (int i);</pre>
5824 Returns the pseudo-index that represents the <code>i</code>-th upvalue of
5833 <span class="apii">[-0, +0, &ndash;]</span>
5834 <pre>lua_Number lua_version (lua_State *L);</pre>
5844 <pre>typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);</pre>
5857 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5864 <span class="apii">[-0, +0, &ndash;]</span>
5865 <pre>void lua_warning (lua_State *L, const char *msg, int tocont);</pre>
5874 See <a href="#pdf-warn"><code>warn</code></a> for more details about warnings.
5881 <pre>typedef int (*lua_Writer) (lua_State *L,
5884 void* ud);</pre>
5906 <span class="apii">[-?, +?, &ndash;]</span>
5907 <pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
5922 <span class="apii">[-?, +?, <em>v</em>]</span>
5923 <pre>int lua_yield (lua_State *L, int nresults);</pre>
5939 <span class="apii">[-?, +?, <em>v</em>]</span>
5940 <pre>int lua_yieldk (lua_State *L,
5943 lua_KFunction k);</pre>
5989 (what is called a <em>C-call boundary</em>),
6002 Lua has no built-in debugging facilities.
6012 <pre>typedef struct lua_Debug {
6031 } lua_Debug;</pre>
6056 the remainder of its contents describes the source in a user-dependent manner.
6087 <code>currentline</code> is set to -1.
6092 Because functions in Lua are first-class values,
6154 <span class="apii">[-0, +0, &ndash;]</span>
6155 <pre>lua_Hook lua_gethook (lua_State *L);</pre>
6165 <span class="apii">[-0, +0, &ndash;]</span>
6166 <pre>int lua_gethookcount (lua_State *L);</pre>
6176 <span class="apii">[-0, +0, &ndash;]</span>
6177 <pre>int lua_gethookmask (lua_State *L);</pre>
6187 <span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
6188 <pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
6209 <pre>
6214 </pre>
6273 <span class="apii">[-0, +(0|1), &ndash;]</span>
6274 <pre>const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
6287 see <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for details about variable indices
6314 <span class="apii">[-0, +0, &ndash;]</span>
6315 <pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
6337 <span class="apii">[-0, +(0|1), &ndash;]</span>
6338 <pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
6341 Gets information about the <code>n</code>-th upvalue
6350 See <a href="#pdf-debug.getupvalue"><code>debug.getupvalue</code></a> for more information about up…
6357 <pre>typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);</pre>
6367 <a name="pdf-LUA_HOOKCALL"><code>LUA_HOOKCALL</code></a>, <a name="pdf-LUA_HOOKRET"><code>LUA_HOOKR…
6368 <a name="pdf-LUA_HOOKTAILCALL"><code>LUA_HOOKTAILCALL</code></a>, <a name="pdf-LUA_HOOKLINE"><code>…
6369 and <a name="pdf-LUA_HOOKCOUNT"><code>LUA_HOOKCOUNT</code></a>.
6390 …allk</code></a>, or <a href="#lua_callk"><code>lua_callk</code></a> with a non-null <code>k</code>.
6405 <span class="apii">[-0, +0, &ndash;]</span>
6406 <pre>void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
6416 <a name="pdf-LUA_MASKCALL"><code>LUA_MASKCALL</code></a>,
6417 <a name="pdf-LUA_MASKRET"><code>LUA_MASKRET</code></a>,
6418 <a name="pdf-LUA_MASKLINE"><code>LUA_MASKLINE</code></a>,
6419 and <a name="pdf-LUA_MASKCOUNT"><code>LUA_MASKCOUNT</code></a>.
6455 <span class="apii">[-(0|1), +0, &ndash;]</span>
6456 <pre>const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
6479 <span class="apii">[-(0|1), +0, &ndash;]</span>
6480 <pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
6503 <span class="apii">[-0, +0, &ndash;]</span>
6504 <pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
6529 <span class="apii">[-0, +0, &ndash;]</span>
6530 <pre>void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
6531 int funcindex2, int n2);</pre>
6534 Make the <code>n1</code>-th upvalue of the Lua closure at index <code>funcindex1</code>
6535 refer to the <code>n2</code>-th upvalue of the Lua closure at index <code>funcindex2</code>.
6553 the auxiliary library provides higher-level functions for some
6604 <span class="apii">[-?, +?, <em>m</em>]</span>
6605 <pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
6616 <span class="apii">[-?, +?, <em>m</em>]</span>
6617 <pre>const void luaL_addgsub (luaL_Buffer *B, const char *s,
6618 const char *p, const char *r);</pre>
6630 <span class="apii">[-?, +?, <em>m</em>]</span>
6631 <pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
6644 <span class="apii">[-?, +?, &ndash;]</span>
6645 <pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
6657 <span class="apii">[-?, +?, <em>m</em>]</span>
6658 <pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
6661 Adds the zero-terminated string pointed to by <code>s</code>
6670 <span class="apii">[-?, +?, <em>m</em>]</span>
6671 <pre>void luaL_addvalue (luaL_Buffer *B);</pre>
6690 <span class="apii">[-0, +0, <em>v</em>]</span>
6691 <pre>void luaL_argcheck (lua_State *L,
6694 const char *extramsg);</pre>
6705 <span class="apii">[-0, +0, <em>v</em>]</span>
6706 <pre>int luaL_argerror (lua_State *L, int arg, const char *extramsg);</pre>
6714 <pre>
6716 </pre><p>
6724 <span class="apii">[-0, +0, <em>v</em>]</span>
6725 <pre>void luaL_argexpected (lua_State *L,
6728 const char *tname);</pre>
6740 <pre>typedef struct luaL_Buffer luaL_Buffer;</pre>
6811 <span class="apii">[-0, +0, &ndash;]</span>
6812 <pre>char *luaL_buffaddr (luaL_Buffer *B);</pre>
6824 <span class="apii">[-0, +?, &ndash;]</span>
6825 <pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
6838 <span class="apii">[-0, +0, &ndash;]</span>
6839 <pre>size_t luaL_bufflen (luaL_Buffer *B);</pre>
6850 <span class="apii">[-?, +?, <em>m</em>]</span>
6851 <pre>char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
6862 <span class="apii">[-?, +?, &ndash;]</span>
6863 <pre>void luaL_buffsub (luaL_Buffer *B, int n);</pre>
6875 <span class="apii">[-0, +(0|1), <em>e</em>]</span>
6876 <pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
6896 <span class="apii">[-0, +0, <em>v</em>]</span>
6897 <pre>void luaL_checkany (lua_State *L, int arg);</pre>
6908 <span class="apii">[-0, +0, <em>v</em>]</span>
6909 <pre>lua_Integer luaL_checkinteger (lua_State *L, int arg);</pre>
6921 <span class="apii">[-0, +0, <em>v</em>]</span>
6922 <pre>const char *luaL_checklstring (lua_State *L, int arg, size_t *l);</pre>
6940 <span class="apii">[-0, +0, <em>v</em>]</span>
6941 <pre>lua_Number luaL_checknumber (lua_State *L, int arg);</pre>
6952 <span class="apii">[-0, +0, <em>v</em>]</span>
6953 <pre>int luaL_checkoption (lua_State *L,
6956 const char *const lst[]);</pre>
6961 (which must be NULL-terminated).
6983 <span class="apii">[-0, +0, <em>v</em>]</span>
6984 <pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
6997 <span class="apii">[-0, +0, <em>v</em>]</span>
6998 <pre>const char *luaL_checkstring (lua_State *L, int arg);</pre>
7014 <span class="apii">[-0, +0, <em>v</em>]</span>
7015 <pre>void luaL_checktype (lua_State *L, int arg, int t);</pre>
7026 <span class="apii">[-0, +0, <em>v</em>]</span>
7027 <pre>void *luaL_checkudata (lua_State *L, int arg, const char *tname);</pre>
7032 returns the userdata's memory-block address (see <a href="#lua_touserdata"><code>lua_touserdata</co…
7039 <span class="apii">[-0, +0, <em>v</em>]</span>
7040 <pre>void luaL_checkversion (lua_State *L);</pre>
7051 <span class="apii">[-0, +?, <em>m</em>]</span>
7052 <pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
7058 <pre>
7060 </pre><p>
7061 It returns&nbsp;0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) if there are no errors,
7069 <span class="apii">[-0, +?, &ndash;]</span>
7070 <pre>int luaL_dostring (lua_State *L, const char *str);</pre>
7076 <pre>
7078 </pre><p>
7079 It returns&nbsp;0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) if there are no errors,
7087 <span class="apii">[-0, +0, <em>v</em>]</span>
7088 <pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
7110 <span class="apii">[-0, +3, <em>m</em>]</span>
7111 <pre>int luaL_execresult (lua_State *L, int stat);</pre>
7115 process-related functions in the standard library
7116 (<a href="#pdf-os.execute"><code>os.execute</code></a> and <a href="#pdf-io.close"><code>io.close</…
7123 <span class="apii">[-0, +(1|3), <em>m</em>]</span>
7124 <pre>int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre>
7128 file-related functions in the standard library
7129 (<a href="#pdf-io.open"><code>io.open</code></a>, <a href="#pdf-os.rename"><code>os.rename</code></…
7136 <span class="apii">[-0, +(0|1), <em>m</em>]</span>
7137 <pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
7151 <span class="apii">[-0, +1, <em>m</em>]</span>
7152 <pre>int luaL_getmetatable (lua_State *L, const char *tname);</pre>
7165 <span class="apii">[-0, +1, <em>e</em>]</span>
7166 <pre>int luaL_getsubtable (lua_State *L, int idx, const char *fname);</pre>
7181 <span class="apii">[-0, +1, <em>m</em>]</span>
7182 <pre>const char *luaL_gsub (lua_State *L,
7185 const char *r);</pre>
7198 <span class="apii">[-0, +0, <em>e</em>]</span>
7199 <pre>lua_Integer luaL_len (lua_State *L, int index);</pre>
7213 <span class="apii">[-0, +1, &ndash;]</span>
7214 <pre>int luaL_loadbuffer (lua_State *L,
7217 const char *name);</pre>
7227 <span class="apii">[-0, +1, &ndash;]</span>
7228 <pre>int luaL_loadbufferx (lua_State *L,
7232 const char *mode);</pre>
7251 <span class="apii">[-0, +1, <em>m</em>]</span>
7252 <pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
7262 <span class="apii">[-0, +1, <em>m</em>]</span>
7263 <pre>int luaL_loadfilex (lua_State *L, const char *filename,
7264 const char *mode);</pre>
7281 or <a href="#pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a> for file-related errors.
7293 <span class="apii">[-0, +1, &ndash;]</span>
7294 <pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
7299 the zero-terminated string <code>s</code>.
7315 <span class="apii">[-0, +1, <em>m</em>]</span>
7316 <pre>void luaL_newlib (lua_State *L, const luaL_Reg l[]);</pre>
7326 <pre>
7328 </pre><p>
7337 <span class="apii">[-0, +1, <em>m</em>]</span>
7338 <pre>void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);</pre>
7358 <span class="apii">[-0, +1, <em>m</em>]</span>
7359 <pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
7381 <span class="apii">[-0, +0, &ndash;]</span>
7382 <pre>lua_State *luaL_newstate (void);</pre>
7401 <span class="apii">[-0, +0, <em>e</em>]</span>
7402 <pre>void luaL_openlibs (lua_State *L);</pre>
7412 <span class="apii">[-0, +0, &ndash;]</span>
7413 <pre>T luaL_opt (L, func, arg, dflt);</pre>
7418 <pre>
7420 </pre><p>
7433 <span class="apii">[-0, +0, <em>v</em>]</span>
7434 <pre>lua_Integer luaL_optinteger (lua_State *L,
7436 lua_Integer d);</pre>
7451 <span class="apii">[-0, +0, <em>v</em>]</span>
7452 <pre>const char *luaL_optlstring (lua_State *L,
7455 size_t *l);</pre>
7482 <span class="apii">[-0, +0, <em>v</em>]</span>
7483 <pre>lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);</pre>
7497 <span class="apii">[-0, +0, <em>v</em>]</span>
7498 <pre>const char *luaL_optstring (lua_State *L,
7500 const char *d);</pre>
7514 <span class="apii">[-?, +?, <em>m</em>]</span>
7515 <pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
7519 with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
7526 <span class="apii">[-?, +?, <em>m</em>]</span>
7527 <pre>char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
7542 <span class="apii">[-0, +1, &ndash;]</span>
7543 <pre>void luaL_pushfail (lua_State *L);</pre>
7553 <span class="apii">[-?, +1, <em>m</em>]</span>
7554 <pre>void luaL_pushresult (luaL_Buffer *B);</pre>
7565 <span class="apii">[-?, +1, <em>m</em>]</span>
7566 <pre>void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
7576 <span class="apii">[-1, +0, <em>m</em>]</span>
7577 <pre>int luaL_ref (lua_State *L, int t);</pre>
7596 <a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <a name="pdf-LUA_REFNIL"><code>L…
7597 The constant <a name="pdf-LUA_NOREF"><code>LUA_NOREF</code></a> is guaranteed to be different
7605 <pre>typedef struct luaL_Reg {
7608 } luaL_Reg;</pre>
7623 <span class="apii">[-0, +1, <em>e</em>]</span>
7624 <pre>void luaL_requiref (lua_State *L, const char *modname,
7625 lua_CFunction openf, int glb);</pre>
7631 as if that function has been called through <a href="#pdf-require"><code>require</code></a>.
7647 <span class="apii">[-nup, +0, <em>m</em>]</span>
7648 <pre>void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
7674 <span class="apii">[-0, +0, &ndash;]</span>
7675 <pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>
7687 <pre>typedef struct luaL_Stream {
7690 } luaL_Stream;</pre>
7725 <span class="apii">[-0, +0, <em>m</em>]</span>
7726 <pre>void *luaL_testudata (lua_State *L, int arg, const char *tname);</pre>
7738 <span class="apii">[-0, +1, <em>e</em>]</span>
7739 <pre>const char *luaL_tolstring (lua_State *L, int idx, size_t *len);</pre>
7761 <span class="apii">[-0, +1, <em>m</em>]</span>
7762 <pre>void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
7763 int level);</pre>
7777 <span class="apii">[-0, +0, <em>v</em>]</span>
7778 <pre>int luaL_typeerror (lua_State *L, int arg, const char *tname);</pre>
7792 <span class="apii">[-0, +0, &ndash;]</span>
7793 <pre>const char *luaL_typename (lua_State *L, int index);</pre>
7803 <span class="apii">[-0, +0, &ndash;]</span>
7804 <pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
7815 If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a href="#pdf-LUA_REF…
7823 <span class="apii">[-0, +1, <em>m</em>]</span>
7824 <pre>void luaL_where (lua_State *L, int lvl);</pre>
7831 <pre>
7833 </pre><p>
7856 (e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable…
7860 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
7895 <li>basic UTF-8 support (<a href="#6.5">&sect;6.5</a>);</li>
7920 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
7921 <a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
7922 <a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),
7923 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
7924 <a name="pdf-luaopen_utf8"><code>luaopen_utf8</code></a> (for the UTF-8 library),
7925 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
7926 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
7927 <a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
7928 <a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the operating system library),
7929 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
7930 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
7946 <hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
7961 <hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>
7971 Performs a full garbage-collection cycle.
7993 Performs a garbage-collection step.
7997 For non-zero values,
8011 the garbage-collector pause,
8020 the garbage-collector minor multiplier
8037 <hr><h3><a name="pdf-dofile"><code>dofile ([filename])</code></a></h3>
8050 <hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
8070 <hr><h3><a name="pdf-_G"><code>_G</code></a></h3>
8081 <hr><h3><a name="pdf-getmetatable"><code>getmetatable (object)</code></a></h3>
8095 <hr><h3><a name="pdf-ipairs"><code>ipairs (t)</code></a></h3>
8102 <pre>
8104 </pre><p>
8113 <hr><h3><a name="pdf-load"><code>load (chunk [, chunkname [, mode [, env]]])</code></a></h3>
8140 when you load a binary chunk created from a function (see <a href="#pdf-string.dump"><code>string.d…
8144 (A non-main function may not even have an <code>_ENV</code> upvalue.)
8185 <hr><h3><a name="pdf-loadfile"><code>loadfile ([filename [, mode [, env]]])</code></a></h3>
8189 Similar to <a href="#pdf-load"><code>load</code></a>,
8198 <hr><h3><a name="pdf-next"><code>next (table [, index])</code></a></h3>
8226 You should not assign any value to a non-existent field in a table
8235 <hr><h3><a name="pdf-pairs"><code>pairs (t)</code></a></h3>
8246 returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</co…
8249 <pre>
8251 </pre><p>
8256 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
8263 <hr><h3><a name="pdf-pcall"><code>pcall (f [, arg1, &middot;&middot;&middot;])</code></a></h3>
8283 <hr><h3><a name="pdf-print"><code>print (&middot;&middot;&middot;)</code></a></h3>
8287 following the same rules of <a href="#pdf-tostring"><code>tostring</code></a>.
8295 use <a href="#pdf-string.format"><code>string.format</code></a> and <a href="#pdf-io.write"><code>i…
8301 <hr><h3><a name="pdf-rawequal"><code>rawequal (v1, v2)</code></a></h3>
8310 <hr><h3><a name="pdf-rawget"><code>rawget (table, index)</code></a></h3>
8320 <hr><h3><a name="pdf-rawlen"><code>rawlen (v)</code></a></h3>
8330 <hr><h3><a name="pdf-rawset"><code>rawset (table, index, value)</code></a></h3>
8345 <hr><h3><a name="pdf-select"><code>select (index, &middot;&middot;&middot;)</code></a></h3>
8351 a negative number indexes from the end (-1 is the last argument).
8359 <hr><h3><a name="pdf-setmetatable"><code>setmetatable (table, metatable)</code></a></h3>
8382 <hr><h3><a name="pdf-tonumber"><code>tonumber (e [, base])</code></a></h3>
8415 <hr><h3><a name="pdf-tostring"><code>tostring (v)</code></a></h3>
8420 converts it to a string in a human-readable format.
8435 use <a href="#pdf-string.format"><code>string.format</code></a>.
8441 <hr><h3><a name="pdf-type"><code>type (v)</code></a></h3>
8460 <hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
8472 <hr><h3><a name="pdf-warn"><code>warn (msg1, &middot;&middot;&middot;)</code></a></h3>
8482 a one-piece message starting with '<code>@</code>'
8495 <hr><h3><a name="pdf-xpcall"><code>xpcall (f, msgh [, arg1, &middot;&middot;&middot;])</code></a></…
8499 This function is similar to <a href="#pdf-pcall"><code>pcall</code></a>,
8512 which come inside the table <a name="pdf-coroutine"><code>coroutine</code></a>.
8517 <hr><h3><a name="pdf-coroutine.close"><code>coroutine.close (co)</code></a></h3>
8523 closes all its pending to-be-closed variables
8536 <hr><h3><a name="pdf-coroutine.create"><code>coroutine.create (f)</code></a></h3>
8549 <hr><h3><a name="pdf-coroutine.isyieldable"><code>coroutine.isyieldable ([co])</code></a></h3>
8559 it is not inside a non-yieldable C&nbsp;function.
8565 <hr><h3><a name="pdf-coroutine.resume"><code>coroutine.resume (co [, val1, &middot;&middot;&middot;…
8592 <hr><h3><a name="pdf-coroutine.running"><code>coroutine.running ()</code></a></h3>
8603 <hr><h3><a name="pdf-coroutine.status"><code>coroutine.status (co)</code></a></h3>
8622 <hr><h3><a name="pdf-coroutine.wrap"><code>coroutine.wrap (f)</code></a></h3>
8640 <hr><h3><a name="pdf-coroutine.yield"><code>coroutine.yield (&middot;&middot;&middot;)</code></a></…
8659 <a href="#pdf-require"><code>require</code></a>.
8660 Everything else is exported in the table <a name="pdf-package"><code>package</code></a>.
8664 <hr><h3><a name="pdf-require"><code>require (modname)</code></a></h3>
8669 The function starts by looking into the <a href="#pdf-package.loaded"><code>package.loaded</code></…
8680 <code>require</code> is guided by the table <a href="#pdf-package.searchers"><code>package.searcher…
8686 for <a href="#pdf-package.searchers"><code>package.searchers</code></a>.
8694 path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
8696 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
8698 it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.searchers"><code>package.searcher…
8712 If the loader returns any non-nil value,
8714 If the loader does not return a non-nil value and
8733 <hr><h3><a name="pdf-package.config"><code>package.config</code></a></h3>
8737 A string describing some compile-time configurations for packages.
8758 Default is '<code>-</code>'.</li>
8765 <hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
8769 A string with the path used by <a href="#pdf-require"><code>require</code></a>
8774 Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the …
8775 it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
8776 using the environment variable <a name="pdf-LUA_CPATH_5_4"><code>LUA_CPATH_5_4</code></a>,
8777 or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>,
8784 <hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
8788 A table used by <a href="#pdf-require"><code>require</code></a> to control which
8792 <a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
8798 table used by <a href="#pdf-require"><code>require</code></a>.
8800 indexed by the key <a name="pdf-LUA_LOADED_TABLE"><code>LUA_LOADED_TABLE</code></a>, a string.
8806 <hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
8826 This is a low-level function.
8828 Unlike <a href="#pdf-require"><code>require</code></a>,
8859 <hr><h3><a name="pdf-package.path"><code>package.path</code></a></h3>
8863 A string with the path used by <a href="#pdf-require"><code>require</code></a>
8868 At start-up, Lua initializes this variable with
8869 the value of the environment variable <a name="pdf-LUA_PATH_5_4"><code>LUA_PATH_5_4</code></a> or
8870 the environment variable <a name="pdf-LUA_PATH"><code>LUA_PATH</code></a> or
8880 <hr><h3><a name="pdf-package.preload"><code>package.preload</code></a></h3>
8885 (see <a href="#pdf-require"><code>require</code></a>).
8891 table used by <a href="#pdf-require"><code>require</code></a>.
8893 indexed by the key <a name="pdf-LUA_PRELOAD_TABLE"><code>LUA_PRELOAD_TABLE</code></a>, a string.
8899 <hr><h3><a name="pdf-package.searchers"><code>package.searchers</code></a></h3>
8903 A table used by <a href="#pdf-require"><code>require</code></a> to control how to find modules.
8909 <a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
8910 with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
8916 returned as a second result by <a href="#pdf-require"><code>require</code></a>.
8928 <a href="#pdf-package.preload"><code>package.preload</code></a> table.
8933 using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
8934 The search is done as described in function <a href="#pdf-package.searchpath"><code>package.searchp…
8939 using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
8941 the search is done as described in function <a href="#pdf-package.searchpath"><code>package.searchp…
8945 <pre>
8947 </pre><p>
8961 For instance, if the module name is <code>a.b.c-v2.1</code>,
8966 The fourth searcher tries an <em>all-in-one loader</em>.
8982 as returned by <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
8995 <hr><h3><a name="pdf-package.searchpath"><code>package.searchpath (name, path [, sep [, rep]])</cod…
9018 <pre>
9020 </pre><p>
9050 Thus, the last character is at position -1, and so on.
9055 <a name="pdf-string"><code>string</code></a>.
9058 Therefore, you can use the string functions in object-oriented style.
9064 The string library assumes one-byte character encodings.
9068 <hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
9074 following the same rules of function <a href="#pdf-string.sub"><code>string.sub</code></a>.
9084 <hr><h3><a name="pdf-string.char"><code>string.char (&middot;&middot;&middot;)</code></a></h3>
9098 <hr><h3><a name="pdf-string.dump"><code>string.dump (function [, strip])</code></a></h3>
9105 so that a later <a href="#pdf-load"><code>load</code></a> on this string returns
9117 (See the <a href="#pdf-load"><code>load</code></a> function for details about
9127 <hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
9155 <hr><h3><a name="pdf-string.format"><code>string.format (formatstring, &middot;&middot;&middot;)</c…
9182 <pre>
9184 </pre><p>
9187 <pre>
9190 </pre><p>
9209 it is converted to one following the same rules of <a href="#pdf-tostring"><code>tostring</code></a…
9227 <hr><h3><a name="pdf-string.gmatch"><code>string.gmatch (s, pattern [, init])</code></a></h3>
9244 <pre>
9249 </pre><p>
9253 <pre>
9259 </pre>
9269 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
9285 stands for the value of the <em>d</em>-th captured substring;
9319 <pre>
9321 --&gt; x="hello hello world world"
9324 --&gt; x="hello hello world"
9327 --&gt; x="world hello Lua from"
9330 --&gt; x="home = /home/roberto, user = roberto"
9332 x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
9335 --&gt; x="4+5 = 9"
9338 x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
9339 --&gt; x="lua-5.4.tar.gz"
9340 </pre>
9345 <hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
9358 <hr><h3><a name="pdf-string.lower"><code>string.lower (s)</code></a></h3>
9371 <hr><h3><a name="pdf-string.match"><code>string.match (s, pattern [, init])</code></a></h3>
9390 <hr><h3><a name="pdf-string.pack"><code>string.pack (fmt, v1, v2, &middot;&middot;&middot;)</code><…
9402 <hr><h3><a name="pdf-string.packsize"><code>string.packsize (fmt)</code></a></h3>
9406 Returns the length of a string resulting from <a href="#pdf-string.pack"><code>string.pack</code></…
9408 The format string cannot have the variable-length options
9415 <hr><h3><a name="pdf-string.rep"><code>string.rep (s, n [, sep])</code></a></h3>
9434 <hr><h3><a name="pdf-string.reverse"><code>string.reverse (s)</code></a></h3>
9444 <hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
9451 If <code>j</code> is absent, then it is assumed to be equal to -1
9456 and <code>string.sub(s, -i)</code> (for a positive <code>i</code>)
9475 <hr><h3><a name="pdf-string.unpack"><code>string.unpack (fmt, s [, pos])</code></a></h3>
9479 Returns the values packed in string <code>s</code> (see <a href="#pdf-string.pack"><code>string.pac…
9490 <hr><h3><a name="pdf-string.upper"><code>string.upper (s)</code></a></h3>
9511 which are interpreted as patterns by the pattern-matching functions
9512 <a href="#pdf-string.find"><code>string.find</code></a>,
9513 <a href="#pdf-string.gmatch"><code>string.gmatch</code></a>,
9514 <a href="#pdf-string.gsub"><code>string.gsub</code></a>,
9515 and <a href="#pdf-string.match"><code>string.match</code></a>.
9531 <code>^$()%.[]*+-?</code>)
9557 <li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character)
9560 Any non-alphanumeric character
9561 (including all punctuation characters, even the non-magical)
9570 in ascending order, with a '<code>-</code>'.
9576 <code>[0-7]</code> represents the octal digits,
9577 and <code>[0-7%l%-]</code> represents the octal digits plus
9578 the lowercase letters plus the '<code>-</code>' character.
9591 Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code>
9603 For instance, <code>%S</code> represents all non-space characters.
9609 In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.
9638 a single character class followed by '<code>-</code>',
9652 such item matches a substring equal to the <em>n</em>-th captured string
9661 counting <em>+1</em> for an <em>x</em> and <em>-1</em> for a <em>y</em>,
9696 A pattern can contain sub-patterns enclosed in parentheses;
9719 The function <a href="#pdf-string.gsub"><code>string.gsub</code></a> and the iterator <a href="#pdf
9729 <pre>
9731 --&gt; 1 2
9732 --&gt; 3 3
9733 --&gt; 4 4
9734 </pre><p>
9749 The first argument to <a href="#pdf-string.pack"><code>string.pack</code></a>,
9750 <a href="#pdf-string.packsize"><code>string.packsize</code></a>, and <a href="#pdf-string.unpack"><…
9781 <li><b><code>c<em>n</em></code>: </b>a fixed-sized string with <code>n</code> bytes</li>
9782 <li><b><code>z</code>: </b>a zero-terminated string</li>
9795 each option corresponds to an argument in <a href="#pdf-string.pack"><code>string.pack</code></a>
9796 or a result in <a href="#pdf-string.unpack"><code>string.unpack</code></a>.
9803 <a href="#pdf-string.pack"><code>string.pack</code></a> checks whether the given value fits in the …
9804 <a href="#pdf-string.unpack"><code>string.unpack</code></a> checks whether the read value fits in a…
9820 of mixed-endian formats.
9835 All padding is filled with zeros by <a href="#pdf-string.pack"><code>string.pack</code></a>
9836 and ignored by <a href="#pdf-string.unpack"><code>string.unpack</code></a>.
9844 <h2>6.5 &ndash; <a name="6.5">UTF-8 Support</a></h2>
9847 This library provides basic support for UTF-8 encoding.
9848 It provides all its functions inside the table <a name="pdf-utf8"><code>utf8</code></a>.
9867 as defined in the original UTF-8 specification;
9884 <hr><h3><a name="pdf-utf8.char"><code>utf8.char (&middot;&middot;&middot;)</code></a></h3>
9889 converts each one to its corresponding UTF-8 byte sequence
9896 <hr><h3><a name="pdf-utf8.charpattern"><code>utf8.charpattern</code></a></h3>
9900 The pattern (a string, not a function) "<code>[\0-\x7F\xC2-\xFD][\x80-\xBF]*</code>"
9902 which matches exactly one UTF-8 byte sequence,
9903 assuming that the subject is a valid UTF-8 string.
9909 <hr><h3><a name="pdf-utf8.codes"><code>utf8.codes (s [, lax])</code></a></h3>
9915 <pre>
9917 </pre><p>
9918 will iterate over all UTF-8 characters in string <code>s</code>,
9927 <hr><h3><a name="pdf-utf8.codepoint"><code>utf8.codepoint (s [, i [, j [, lax]]])</code></a></h3>
9940 <hr><h3><a name="pdf-utf8.len"><code>utf8.len (s [, i [, j [, lax]]])</code></a></h3>
9944 Returns the number of UTF-8 characters in string <code>s</code>
9946 The default for <code>i</code> is 1 and for <code>j</code> is -1.
9954 <hr><h3><a name="pdf-utf8.offset"><code>utf8.offset (s, n [, i])</code></a></h3>
9959 <code>n</code>-th character of <code>s</code>
9962 The default for <code>i</code> is 1 when <code>n</code> is non-negative
9964 so that <code>utf8.offset(s, -n)</code> gets the offset of the
9965 <code>n</code>-th character from the end of the string.
9974 of the character that contains the <code>i</code>-th byte of <code>s</code>.
9978 This function assumes that <code>s</code> is a valid UTF-8 string.
9990 It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.
9996 All functions ignore non-numeric keys
10001 <hr><h3><a name="pdf-table.concat"><code>table.concat (list [, sep [, i [, j]]])</code></a></h3>
10016 <hr><h3><a name="pdf-table.insert"><code>table.insert (list, [pos,] value)</code></a></h3>
10031 <hr><h3><a name="pdf-table.move"><code>table.move (a1, f, e, t [,a2])</code></a></h3>
10051 <hr><h3><a name="pdf-table.pack"><code>table.pack (&middot;&middot;&middot;)</code></a></h3>
10064 <hr><h3><a name="pdf-table.remove"><code>table.remove (list [, pos])</code></a></h3>
10087 <hr><h3><a name="pdf-table.sort"><code>table.sort (list [, comp])</code></a></h3>
10091 Sorts the list elements in a given order, <em>in-place</em>,
10119 <hr><h3><a name="pdf-table.unpack"><code>table.unpack (list [, i [, j]])</code></a></h3>
10126 <pre>
10128 </pre><p>
10141 It provides all its functions and constants inside the table <a name="pdf-math"><code>math</code></…
10144 and float results for non-integer arguments.
10146 <a href="#pdf-math.ceil"><code>math.ceil</code></a>, <a href="#pdf-math.floor"><code>math.floor</co…
10152 <hr><h3><a name="pdf-math.abs"><code>math.abs (x)</code></a></h3>
10156 Returns the maximum value between <code>x</code> and <code>-x</code>. (integer/float)
10162 <hr><h3><a name="pdf-math.acos"><code>math.acos (x)</code></a></h3>
10172 <hr><h3><a name="pdf-math.asin"><code>math.asin (x)</code></a></h3>
10182 <hr><h3><a name="pdf-math.atan"><code>math.atan (y [, x])</code></a></h3>
10202 <hr><h3><a name="pdf-math.ceil"><code>math.ceil (x)</code></a></h3>
10212 <hr><h3><a name="pdf-math.cos"><code>math.cos (x)</code></a></h3>
10222 <hr><h3><a name="pdf-math.deg"><code>math.deg (x)</code></a></h3>
10232 <hr><h3><a name="pdf-math.exp"><code>math.exp (x)</code></a></h3>
10243 <hr><h3><a name="pdf-math.floor"><code>math.floor (x)</code></a></h3>
10253 <hr><h3><a name="pdf-math.fmod"><code>math.fmod (x, y)</code></a></h3>
10264 <hr><h3><a name="pdf-math.huge"><code>math.huge</code></a></h3>
10275 <hr><h3><a name="pdf-math.log"><code>math.log (x [, base])</code></a></h3>
10287 <hr><h3><a name="pdf-math.max"><code>math.max (x, &middot;&middot;&middot;)</code></a></h3>
10298 <hr><h3><a name="pdf-math.maxinteger"><code>math.maxinteger</code></a></h3>
10305 <hr><h3><a name="pdf-math.min"><code>math.min (x, &middot;&middot;&middot;)</code></a></h3>
10316 <hr><h3><a name="pdf-math.mininteger"><code>math.mininteger</code></a></h3>
10323 <hr><h3><a name="pdf-math.modf"><code>math.modf (x)</code></a></h3>
10334 <hr><h3><a name="pdf-math.pi"><code>math.pi</code></a></h3>
10344 <hr><h3><a name="pdf-math.rad"><code>math.rad (x)</code></a></h3>
10354 <hr><h3><a name="pdf-math.random"><code>math.random ([m [, n]])</code></a></h3>
10359 returns a pseudo-random float with uniform distribution
10362 <code>math.random</code> returns a pseudo-random integer
10372 pseudo-random 64-bit integers,
10379 Lua initializes its pseudo-random generator with the equivalent of
10380 a call to <a href="#pdf-math.randomseed"><code>math.randomseed</code></a> with no arguments,
10388 <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed ([x [, y]])</code></a></h3>
10394 joined into a 128-bit <em>seed</em> that
10395 is used to reinitialize the pseudo-random generator;
10416 you should call <a href="#pdf-math.randomseed"><code>math.randomseed</code></a> with explicit argum…
10422 <hr><h3><a name="pdf-math.sin"><code>math.sin (x)</code></a></h3>
10432 <hr><h3><a name="pdf-math.sqrt"><code>math.sqrt (x)</code></a></h3>
10443 <hr><h3><a name="pdf-math.tan"><code>math.tan (x)</code></a></h3>
10453 <hr><h3><a name="pdf-math.tointeger"><code>math.tointeger (x)</code></a></h3>
10465 <hr><h3><a name="pdf-math.type"><code>math.type (x)</code></a></h3>
10477 <hr><h3><a name="pdf-math.ult"><code>math.ult (m, n)</code></a></h3>
10504 all operations are supplied by table <a name="pdf-io"><code>io</code></a>.
10506 the operation <a href="#pdf-io.open"><code>io.open</code></a> returns a file handle
10519 <a name="pdf-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a…
10527 a system-dependent error code as a third result,
10528 and some non-false value on success.
10529 On non-POSIX systems,
10537 <hr><h3><a name="pdf-io.close"><code>io.close ([file])</code></a></h3>
10548 <hr><h3><a name="pdf-io.flush"><code>io.flush ()</code></a></h3>
10558 <hr><h3><a name="pdf-io.input"><code>io.input ([file])</code></a></h3>
10578 <hr><h3><a name="pdf-io.lines"><code>io.lines ([filename, &middot;&middot;&middot;])</code></a></h3>
10612 <hr><h3><a name="pdf-io.open"><code>io.open (filename [, mode])</code></a></h3>
10641 <hr><h3><a name="pdf-io.output"><code>io.output ([file])</code></a></h3>
10645 Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output …
10651 <hr><h3><a name="pdf-io.popen"><code>io.popen (prog [, mode])</code></a></h3>
10670 <hr><h3><a name="pdf-io.read"><code>io.read (&middot;&middot;&middot;)</code></a></h3>
10680 <hr><h3><a name="pdf-io.tmpfile"><code>io.tmpfile ()</code></a></h3>
10693 <hr><h3><a name="pdf-io.type"><code>io.type (obj)</code></a></h3>
10706 <hr><h3><a name="pdf-io.write"><code>io.write (&middot;&middot;&middot;)</code></a></h3>
10716 <hr><h3><a name="pdf-file:close"><code>file:close ()</code></a></h3>
10727 When closing a file handle created with <a href="#pdf-io.popen"><code>io.popen</code></a>,
10728 <a href="#pdf-file:close"><code>file:close</code></a> returns the same values
10729 returned by <a href="#pdf-os.execute"><code>os.execute</code></a>.
10735 <hr><h3><a name="pdf-file:flush"><code>file:flush ()</code></a></h3>
10745 <hr><h3><a name="pdf-file:lines"><code>file:lines (&middot;&middot;&middot;)</code></a></h3>
10756 <pre>
10758 </pre><p>
10761 Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
10768 <hr><h3><a name="pdf-file:read"><code>file:read (&middot;&middot;&middot;)</code></a></h3>
10796 (e.g., an empty string, "<code>0x</code>", or "<code>3.4e-</code>")
10814 reads the next line keeping the end-of-line character (if present),
10833 <hr><h3><a name="pdf-file:seek"><code>file:seek ([whence [, offset]])</code></a></h3>
10867 <hr><h3><a name="pdf-file:setvbuf"><code>file:setvbuf (mode [, size])</code></a></h3>
10895 <hr><h3><a name="pdf-file:write"><code>file:write (&middot;&middot;&middot;)</code></a></h3>
10915 This library is implemented through table <a name="pdf-os"><code>os</code></a>.
10919 <hr><h3><a name="pdf-os.clock"><code>os.clock ()</code></a></h3>
10931 <hr><h3><a name="pdf-os.date"><code>os.date ([format [, time]])</code></a></h3>
10942 (see the <a href="#pdf-os.time"><code>os.time</code></a> function for a description of this value).
10970 which gives a human-readable date and time representation
10975 On non-POSIX systems,
10983 <hr><h3><a name="pdf-os.difftime"><code>os.difftime (t2, t1)</code></a></h3>
10989 (where the times are values returned by <a href="#pdf-os.time"><code>os.time</code></a>).
10991 this value is exactly <code>t2</code><em>-</em><code>t1</code>.
10997 <hr><h3><a name="pdf-os.execute"><code>os.execute ([command])</code></a></h3>
11032 <hr><h3><a name="pdf-os.exit"><code>os.exit ([code [, close]])</code></a></h3>
11054 <hr><h3><a name="pdf-os.getenv"><code>os.getenv (varname)</code></a></h3>
11065 <hr><h3><a name="pdf-os.remove"><code>os.remove (filename)</code></a></h3>
11079 <hr><h3><a name="pdf-os.rename"><code>os.rename (oldname, newname)</code></a></h3>
11092 <hr><h3><a name="pdf-os.setlocale"><code>os.setlocale (locale [, category])</code></a></h3>
11097 <code>locale</code> is a system-dependent string specifying a locale;
11108 the current locale is set to an implementation-defined native locale.
11127 <hr><h3><a name="pdf-os.time"><code>os.time ([table])</code></a></h3>
11140 For a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function.
11146 For instance, if <code>sec</code> is -10,
11159 <a href="#pdf-os.date"><code>os.date</code></a> and <a href="#pdf-os.difftime"><code>os.difftime</c…
11165 documented in the <a href="#pdf-os.date"><code>os.date</code></a> function,
11173 <hr><h3><a name="pdf-os.tmpname"><code>os.tmpname ()</code></a></h3>
11195 you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
11222 inside the <a name="pdf-debug"><code>debug</code></a> table.
11230 <hr><h3><a name="pdf-debug.debug"><code>debug.debug ()</code></a></h3>
11251 <hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
11258 as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function.
11268 <hr><h3><a name="pdf-debug.getinfo"><code>debug.getinfo ([thread,] f [, what])</code></a></h3>
11305 about the <a href="#pdf-print"><code>print</code></a> function.
11311 <hr><h3><a name="pdf-debug.getlocal"><code>debug.getlocal ([thread,] f, local)</code></a></h3>
11326 Compile-time constants may not appear in this listing,
11329 -1 is the first vararg argument.
11333 (You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the leve…
11351 <hr><h3><a name="pdf-debug.getmetatable"><code>debug.getmetatable (value)</code></a></h3>
11362 <hr><h3><a name="pdf-debug.getregistry"><code>debug.getregistry ()</code></a></h3>
11372 <hr><h3><a name="pdf-debug.getupvalue"><code>debug.getupvalue (f, up)</code></a></h3>
11402 <hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u, n)</code></a></h3>
11406 Returns the <code>n</code>-th user value associated
11414 <hr><h3><a name="pdf-debug.sethook"><code>debug.sethook ([thread,] hook, mask [, count])</code></a>…
11436 <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> turns off the hook.
11456 <hr><h3><a name="pdf-debug.setlocal"><code>debug.setlocal ([thread,] level, local, value)</code></a…
11470 See <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for more information about
11477 <hr><h3><a name="pdf-debug.setmetatable"><code>debug.setmetatable (value, table)</code></a></h3>
11489 <hr><h3><a name="pdf-debug.setupvalue"><code>debug.setupvalue (f, up, value)</code></a></h3>
11501 See <a href="#pdf-debug.getupvalue"><code>debug.getupvalue</code></a> for more information about up…
11507 <hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value, n)</code></a></h3>
11512 the <code>n</code>-th user value associated to the given <code>udata</code>.
11524 <hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code><…
11542 <hr><h3><a name="pdf-debug.upvalueid"><code>debug.upvalueid (f, n)</code></a></h3>
11562 <hr><h3><a name="pdf-debug.upvaluejoin"><code>debug.upvaluejoin (f1, n1, f2, n2)</code></a></h3>
11566 Make the <code>n1</code>-th upvalue of the Lua closure <code>f1</code>
11567 refer to the <code>n2</code>-th upvalue of the Lua closure <code>f2</code>.
11588 <pre>
11590 </pre><p>
11594 <li><b><code>-e <em>stat</em></code>: </b> execute string <em>stat</em>;</li>
11595 <li><b><code>-i</code>: </b> enter interactive mode after running <em>script</em>;</li>
11596 <li><b><code>-l <em>mod</em></code>: </b> "require" <em>mod</em> and assign the
11598 <li><b><code>-l <em>g=mod</em></code>: </b> "require" <em>mod</em> and assign the
11600 <li><b><code>-v</code>: </b> print version information;</li>
11601 <li><b><code>-E</code>: </b> ignore environment variables;</li>
11602 <li><b><code>-W</code>: </b> turn warnings on;</li>
11603 <li><b><code>--</code>: </b> stop handling options;</li>
11604 <li><b><code>-</code>: </b> execute <code>stdin</code> as a file and stop handling options.</li>
11606 (The form <code>-l <em>g=mod</em></code> was introduced in release&nbsp;5.4.4.)
11612 <code>lua</code> behaves as <code>lua -v -i</code>
11614 and as <code>lua -</code> otherwise.
11618 When called without the option <code>-E</code>,
11619 the interpreter checks for an environment variable <a name="pdf-LUA_INIT_5_4"><code>LUA_INIT_5_4</c…
11620 (or <a name="pdf-LUA_INIT"><code>LUA_INIT</code></a> if the versioned name is not defined)
11628 When called with the option <code>-E</code>,
11631 the values of <a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.c…
11634 the stand-alone interpreter sets the field
11640 The options <code>-e</code>, <code>-l</code>, and <code>-W</code> are handled in
11644 <pre>
11645 $ lua -e 'a=1' -llib1 script.lua
11646 </pre><p>
11654 <code>lua</code> collects all command-line arguments
11664 <pre>
11665 $ lua -la b.lua t1 t2
11666 </pre><p>
11669 <pre>
11670 arg = { [-2] = "lua", [-1] = "-la",
11673 </pre><p>
11679 <pre>
11680 $ lua -e "print(arg[1])"
11681 </pre><p>
11682 will print "<code>-e</code>".
11703 If the global variable <a name="pdf-_PROMPT"><code>_PROMPT</code></a> contains a string,
11705 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a strin…
11727 calling <a href="#pdf-os.exit"><code>os.exit</code></a> to terminate.
11738 <pre>
11740 </pre><p>
11746 <pre>
11748 </pre><p>
11778 do not imply source-code changes in a program,
11849 (Non-callable values will generate a warning,
11862 The function <a href="#pdf-print"><code>print</code></a> does not call <a href="#pdf-tostring"><cod…
11869 The pseudo-random number generator used by the function <a href="#pdf-math.random"><code>math.rando…
11875 By default, the decoding functions in the <a href="#pdf-utf8"><code>utf8</code></a> library
11882 of the function <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> are deprecated.
11887 The function <a href="#pdf-io.lines"><code>io.lines</code></a> now returns four values,
11920 are more efficient memory-wise.
11972 <pre>
12035 …binop ::= &lsquo;<b>+</b>&rsquo; | &lsquo;<b>-</b>&rsquo; | &lsquo;<b>*</b>&rsquo; | &lsquo;<b>/<…
12040 unop ::= &lsquo;<b>-</b>&rsquo; | <b>not</b> | &lsquo;<b>#</b>&rsquo; | &lsquo;<b>~</b>&rsquo;
12042 </pre>
12055 <!--
12057 -->