• Home
  • Raw
  • Download

Lines Matching full:code

59 The host program can invoke functions to execute a piece of Lua code,
61 and can register C functions to be called by Lua code.
65 The Lua distribution includes a sample host program called <code>lua</code>,
75 at Lua's official web site, <code>www.lua.org</code>.
129 see file <code>luaconf.h</code>.)
134 including embedded zeros ('<code>\0</code>').
173 undefined or unrepresentable results, such as <code>0/0</code>).
187 providing <code>a.name</code> as syntactic sugar for <code>a["name"]</code>.
211 The expressions <code>a[i]</code> and <code>a[j]</code>
213 if and only if <code>i</code> and <code>j</code> are raw equal
227 The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
238 any reference to a global name <code>var</code> is syntactically translated
239 to <code>_ENV.var</code>.
241 an external local variable called <code>_ENV</code> (see <a href="#3.3.2">&sect;3.3.2</a>),
242 so <code>_ENV</code> itself is never a global name in a chunk.
246 Despite the existence of this external <code>_ENV</code> variable and
248 <code>_ENV</code> is a completely regular name.
251 Each reference to a global name uses the <code>_ENV</code> that is
257 Any table used as the value of <code>_ENV</code> is called an <em>environment</em>.
263 In Lua, the variable <a href="#pdf-_G"><code>_G</code></a> is initialized with this same value.
268 it initializes the value of its <code>_ENV</code> upvalue
269 with the global environment (see <a href="#pdf-load"><code>load</code></a>).
271 global variables in Lua code refer to entries in the global environment.
274 You can use <a href="#pdf-load"><code>load</code></a> (or <a href="#pdf-loadfile"><code>loadfile</c…
282 (through C code or the debug library),
285 as each has its own reference to the environment in its <code>_ENV</code> variable.
286 Moreover, the variable <a href="#pdf-_G"><code>_G</code></a>
298 all Lua actions start from C&nbsp;code in the host program
299 calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
308 Lua code can explicitly generate an error by calling the
309 <a href="#pdf-error"><code>error</code></a> function.
311 you can use <a href="#pdf-pcall"><code>pcall</code></a> or <a href="#pdf-xpcall"><code>xpcall</code
325 When you use <a href="#pdf-xpcall"><code>xpcall</code></a> or <a href="#lua_pcall"><code>lua_pcall<…
352 Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
360 In the previous example, the event is <code>"add"</code>
366 using the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.
371 using the <a href="#pdf-setmetatable"><code>setmetatable</code></a> function.
402 two underscores, '<code>__</code>';
404 string "<code>__add</code>".
410 The code shown here in Lua is only illustrative;
414 (<a href="#pdf-rawget"><code>rawget</code></a>, <a href="#pdf-tonumber"><code>tonumber</code></a>, …
433 For the unary <code>-</code> and <code>#</code> operators,
437 in the following code.
445 the <code>+</code> operation.
450 The function <code>getbinhandler</code> below defines how Lua chooses a handler
462 the behavior of the <code>op1 + op2</code> is
483 the <code>-</code> operation.
489 the <code>*</code> operation.
495 the <code>/</code> operation.
501 the <code>%</code> operation.
505 <code>o1 - floor(o1/o2)*o2</code> as the primitive operation.
509 the <code>^</code> (exponentiation) operation.
512 with the function <code>pow</code> (from the C&nbsp;math library)
517 the unary <code>-</code> operation.
540 the <code>..</code> (concatenation) operation.
561 the <code>#</code> operation.
584 the <code>==</code> operation.
586 The function <code>getequalhandler</code> defines how Lua chooses a metamethod
624 the <code>&lt;</code> operation.
647 the <code>&lt;=</code> operation.
672 Lua tries the "lt", assuming that <code>a &lt;= b</code> is
673 equivalent to <code>not (b &lt; a)</code>.
682 The indexing access <code>table[key]</code>.
684 when <code>key</code> is not present in <code>table</code>.
685 (When <code>table</code> is not a table,
714 The indexing assignment <code>table[key] = value</code>.
716 when <code>key</code> is not present in <code>table</code>.
825 You can change these numbers by calling <a href="#lua_gc"><code>lua_gc</code></a> in C
826 or <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> in Lua.
865 and the metatable has a field indexed by the string "<code>__gc</code>".
866 Note that if you set a metatable without a <code>__gc</code> field
870 you can freely change the <code>__gc</code> field of its metatable.
898 the execution of the regular code.
916 When you close a state (see <a href="#lua_close"><code>lua_close</code></a>),
946 <code>__mode</code> field of its metatable.
947 If the <code>__mode</code> field is a string containing the character&nbsp;'<code>k</code>',
949 If <code>__mode</code> contains '<code>v</code>',
1017 You create a coroutine by calling <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
1020 The <code>create</code> function only creates a new coroutine and
1026 You execute a coroutine by calling <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a…
1027 When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
1029 a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
1032 Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are pas…
1043 In the first case, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>tru…
1045 In case of errors, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>fal…
1050 A coroutine yields by calling <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
1052 the corresponding <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns immedia…
1056 In the case of a yield, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> also retu…
1057 plus any values passed to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
1060 with the call to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a> returning any extra
1061 arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
1065 Like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
1066 the <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function also creates a coroutine,
1070 go as extra arguments to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
1071 …utine.wrap"><code>coroutine.wrap</code></a> returns all the values returned by <a href="#pdf-corou…
1072 except the first one (the boolean error code).
1073 Unlike <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
1074 <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> does not catch errors;
1080 consider the following code:
1117 …ee functions <a href="#lua_newthread"><code>lua_newthread</code></a>, <a href="#lua_resume"><code>…
1118 and <a href="#lua_yield"><code>lua_yield</code></a>.
1180 <code>and</code> is a reserved word, but <code>And</code> and <code>AND</code>
1183 uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>)
1201 '<code>\a</code>' (bell),
1202 '<code>\b</code>' (backspace),
1203 '<code>\f</code>' (form feed),
1204 '<code>\n</code>' (newline),
1205 '<code>\r</code>' (carriage return),
1206 '<code>\t</code>' (horizontal tab),
1207 '<code>\v</code>' (vertical tab),
1208 '<code>\\</code>' (backslash),
1209 '<code>\"</code>' (quotation mark [double quote]),
1210 and '<code>\'</code>' (apostrophe [single quote]).
1213 The escape sequence '<code>\z</code>' skips the following span
1223 This can be done with the escape sequence <code>\x<em>XX</em></code>,
1225 or with the escape sequence <code>\<em>ddd</em></code>,
1230 which can be specified as '<code>\0</code>'.
1239 So, an opening long bracket of level&nbsp;0 is written as <code>[[</code>,
1240 an opening long bracket of level&nbsp;1 is written as <code>[=[</code>,
1243 for instance, a closing long bracket of level&nbsp;4 is written as <code>]====]</code>.
1272 (in which '<code>a</code>' is coded as&nbsp;97,
1273 newline is coded as&nbsp;10, and '<code>1</code>' is coded as&nbsp;49),
1290 marked by a letter '<code>e</code>' or '<code>E</code>'.
1292 which start with <code>0x</code> or <code>0X</code>.
1295 marked by a letter '<code>p</code>' or '<code>P</code>'.
1304 A <em>comment</em> starts with a double hyphen (<code>--</code>)
1306 If the text immediately after <code>--</code> is not an opening long bracket,
1311 Long comments are frequently used to disable code temporarily.
1355 An access to an indexed variable <code>t[i]</code> is equivalent to
1356 a call <code>gettable_event(t,i)</code>.
1358 <code>gettable_event</code> function.
1364 The syntax <code>var.Name</code> is just syntactic sugar for
1365 <code>var["Name"]</code>:
1372 An access to a global variable <code>x</code>
1373 is equivalent to <code>_ENV.x</code>.
1375 <code>_ENV</code> is never a global name (see <a href="#2.2">&sect;2.2</a>).
1473 scope of an external local variable called <code>_ENV</code> (see <a href="#2.2">&sect;2.2</a>).
1474 The resulting function always has <code>_ENV</code> as its only upvalue,
1482 and then it executes the compiled code
1488 see program <code>luac</code> for details.
1531 Thus the code
1537 sets <code>a[3]</code> to 20, without affecting <code>a[4]</code>
1538 because the <code>i</code> in <code>a[i]</code> is evaluated (to 3)
1545 exchanges the values of <code>x</code> and <code>y</code>,
1551 cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>.
1557 An assignment to an indexed variable <code>t[i] = val</code> is equivalent to
1558 <code>settable_event(t,i,val)</code>.
1560 <code>settable_event</code> function.
1566 An assignment to a global variable <code>x = val</code>
1568 <code>_ENV.x = val</code> (see <a href="#2.2">&sect;2.2</a>).
1661 as in the idiom <code>do return end</code>,
1677 The numeric <b>for</b> loop repeats a block of code while a
1692 is equivalent to the code:
1716 <code><em>var</em></code>, <code><em>limit</em></code>, and <code><em>step</em></code> are invisibl…
1730 The loop variable <code>v</code> is local to the loop;
1754 is equivalent to the code:
1772 <code><em>explist</em></code> is evaluated only once.
1779 <code><em>f</em></code>, <code><em>s</em></code>, and <code><em>var</em></code> are invisible varia…
1788 The loop variables <code><em>var_i</em></code> are local to the loop;
1864 denoted by three dots ('<code>...</code>'), can only be used when
1918 <code>(f(x,y,z))</code> is always a single value,
1919 even if <code>f</code> returns several values.
1920 (The value of <code>(f(x,y,z))</code> is the first value returned by <code>f</code>
1921 or <b>nil</b> if <code>f</code> does not return any values.)
1927 the binary <code>+</code> (addition),
1928 <code>-</code> (subtraction), <code>*</code> (multiplication),
1929 <code>/</code> (division), <code>%</code> (modulo), and <code>^</code> (exponentiation);
1930 and unary <code>-</code> (mathematical negation).
1935 For instance, <code>x^(-0.5)</code> computes the inverse of the square root of <code>x</code>.
1959 use the <code>format</code> function from the string library
1960 (see <a href="#pdf-string.format"><code>string.format</code></a>).
1976 Equality (<code>==</code>) first compares the type of its operands.
1999 Thus, <code>"0"==0</code> evaluates to <b>false</b>,
2000 and <code>t[0]</code> and <code>t["0"]</code> denote different
2005 The operator <code>~=</code> is exactly the negation of equality (<code>==</code>).
2015 A comparison <code>a &gt; b</code> is translated to <code>b &lt; a</code>
2016 and <code>a &gt;= b</code> is translated to <code>b &lt;= a</code>.
2054 <code>--&gt;</code> indicates the result of the preceding expression.)
2062 denoted by two dots ('<code>..</code>').
2065 Otherwise, the <code>__concat</code> metamethod is called (see <a href="#2.4">&sect;2.4</a>).
2074 The length operator is denoted by the unary prefix operator <code>#</code>.
2082 any value but strings through the <code>__len</code> metamethod (see <a href="#2.4">&sect;2.4</a>).
2086 Unless a <code>__len</code> metamethod is given,
2087 the length of a table <code>t</code> is only defined if the
2098 is not a sequence, because it has the key <code>4</code>
2099 but does not have the key <code>3</code>.
2125 The concatenation ('<code>..</code>') and exponentiation ('<code>^</code>')
2148 Each field of the form <code>[exp1] = exp2</code> adds to the new table an entry
2149 with key <code>exp1</code> and value <code>exp2</code>.
2150 A field of the form <code>name = exp</code> is equivalent to
2151 <code>["name"] = exp</code>.
2152 Finally, fields of the form <code>exp</code> are equivalent to
2153 <code>[i] = exp</code>, where <code>i</code> are consecutive numerical integers,
2178 If the last field in the list has the form <code>exp</code>
2186 as a convenience for machine-generated code.
2216 A call <code>v:name(<em>args</em>)</code>
2217 is syntactic sugar for <code>v.name(v,<em>args</em>)</code>,
2218 except that <code>v</code> is evaluated only once.
2230 A call of the form <code>f{<em>fields</em>}</code> is
2231 syntactic sugar for <code>f({<em>fields</em>})</code>;
2233 A call of the form <code>f'<em>string</em>'</code>
2234 (or <code>f"<em>string</em>"</code> or <code>f[[<em>string</em>]]</code>)
2235 is syntactic sugar for <code>f('<em>string</em>')</code>;
2240 A call of the form <code>return <em>functioncall</em></code> is called
2321 contains references to <code>f</code>.)
2346 which is indicated by three dots ('<code>...</code>')
2405 that is, functions that have an implicit extra parameter <code>self</code>.
2448 Notice that, in a declaration like <code>local x = x</code>,
2449 the new <code>x</code> being declared is not in scope yet,
2450 and so the second <code>x</code> refers to the outside variable.
2477 Each of these closures uses a different <code>y</code> variable,
2478 while all of them share the same <code>x</code>.
2492 are declared in the header file <a name="pdf-lua.h"><code>lua.h</code></a>.
2508 with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a> defined.
2526 to be returned to the caller (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
2557 You can use the function <a href="#lua_checkstack"><code>lua_checkstack</code></a>
2563 it ensures that the stack has at least <a name="pdf-LUA_MINSTACK"><code>LUA_MINSTACK</code></a> ext…
2564 <code>LUA_MINSTACK</code> is defined as 20,
2566 unless your code has loops pushing elements onto the stack.
2571 without a fixed number of results (see <a href="#lua_call"><code>lua_call</code></a>),
2575 you should use <a href="#lua_checkstack"><code>lua_checkstack</code></a>.
2592 (<code>1 &le; abs(index) &le; top</code>).
2601 which represent some Lua values that are accessible to C&nbsp;code
2632 contains a value of a virtual type <a name="pdf-LUA_TNONE"><code>LUA_TNONE</code></a>,
2645 (see <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a>);
2654 <a href="#lua_upvalueindex"><code>lua_upvalueindex</code></a>.
2656 <code>lua_upvalueindex(1)</code>, and so on.
2657 Any access to <code>lua_upvalueindex(<em>n</em>)</code>,
2670 a predefined table that can be used by any C&nbsp;code to
2673 <a name="pdf-LUA_REGISTRYINDEX"><code>LUA_REGISTRYINDEX</code></a>,
2680 or a light userdata with the address of a C&nbsp;object in your code,
2681 or any Lua object created by your code.
2698 defined as constants in <code>lua.h</code>.
2702 <li><b><a name="pdf-LUA_RIDX_MAINTHREAD"><code>LUA_RIDX_MAINTHREAD</code></a>: </b> At this index t…
2707 <li><b><a name="pdf-LUA_RIDX_GLOBALS"><code>LUA_RIDX_GLOBALS</code></a>: </b> At this index the reg…
2718 Internally, Lua uses the C <code>longjmp</code> facility to handle errors.
2720 search for <code>LUAI_THROW</code> in the source code.)
2726 A <em>protected environment</em> uses <code>setjmp</code>
2733 Lua calls a <em>panic function</em> (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>)
2734 and then calls <code>abort</code>,
2757 … C&nbsp;function you can throw an error by calling <a href="#lua_error"><code>lua_error</code></a>.
2766 Internally, Lua uses the C <code>longjmp</code> facility to yield a coroutine.
2767 Therefore, if a function <code>foo</code> calls an API function
2770 Lua cannot return to <code>foo</code> any more,
2771 because the <code>longjmp</code> removes its frame from the C stack.
2778 …#lua_yieldk"><code>lua_yieldk</code></a>, <a href="#lua_callk"><code>lua_callk</code></a>, and <a …
2780 (as a parameter called <code>k</code>) to continue execution after a yield.
2790 (This can happen when the callee function is <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
2791 …unction is either <a href="#lua_callk"><code>lua_callk</code></a> or <a href="#lua_pcallk"><code>l…
2815 after a <a href="#lua_callk"><code>lua_callk</code></a> the function and its arguments are
2824 and its continuation is the result of a call to <a href="#lua_getctx"><code>lua_getctx</code></a>.
2840 The first field, <code>o</code>,
2842 The second field, <code>p</code>,
2845 A field in the form <code>x|y</code> means the function can push (or pop)
2846 <code>x</code> or <code>y</code> elements,
2848 an interrogation mark '<code>?</code>' means that
2852 The third field, <code>x</code>,
2854 '<code>-</code>' means the function never throws any error;
2855 '<code>e</code>' means the function may throw errors;
2856 '<code>v</code>' means the function may throw an error on purpose.
2860 <hr><h3><a name="lua_absindex"><code>lua_absindex</code></a></h3><p>
2865 Converts the acceptable index <code>idx</code> into an absolute index
2872 <hr><h3><a name="lua_Alloc"><code>lua_Alloc</code></a></h3>
2881 functionality similar to <code>realloc</code>,
2884 <code>ud</code>, an opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>;
2885 <code>ptr</code>, a pointer to the block being allocated/reallocated/freed;
2886 <code>osize</code>, the original size of the block or some code about what
2888 <code>nsize</code>, the new size of the block.
2892 When <code>ptr</code> is not <code>NULL</code>,
2893 <code>osize</code> is the size of the block pointed by <code>ptr</code>,
2898 When <code>ptr</code> is <code>NULL</code>,
2899 <code>osize</code> encodes the kind of object that Lua is allocating.
2900 <code>osize</code> is any of
2901 …RING"><code>LUA_TSTRING</code></a>, <a href="#pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>, <a href…
2902 <a href="#pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>, or <a href="#pdf-LUA_TTHREAD"><code>LU…
2904 When <code>osize</code> is some other value,
2913 When <code>nsize</code> is zero,
2914 the allocator should behave like <code>free</code>
2915 and return <code>NULL</code>.
2919 When <code>nsize</code> is not zero,
2920 the allocator should behave like <code>realloc</code>.
2921 The allocator returns <code>NULL</code>
2924 <code>osize &gt;= nsize</code>.
2929 It is used in the auxiliary library by <a href="#luaL_newstate"><code>luaL_newstate</code></a>.
2944 that <code>free(NULL)</code> has no effect and that
2945 <code>realloc(NULL, size)</code> is equivalent to <code>malloc(size)</code>.
2946 This code assumes that <code>realloc</code> does not fail when shrinking a block.
2954 <hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p>
2969 The value of <code>op</code> must be one of the following constants:
2973 <li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>: </b> performs addition (<code>+</code>)<…
2974 <li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>: </b> performs subtraction (<code>-</code
2975 <li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>: </b> performs multiplication (<code>*</c…
2976 <li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>: </b> performs division (<code>/</code>)<…
2977 <li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>: </b> performs modulo (<code>%</code>)</l…
2978 <li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>: </b> performs exponentiation (<code>^</c…
2979 <li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>: </b> performs mathematical negation (una…
2986 <hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
2997 <hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
3011 Finally you call <a href="#lua_call"><code>lua_call</code></a>;
3012 <code>nargs</code> is the number of arguments that you pushed onto the stack.
3016 The number of results is adjusted to <code>nresults</code>,
3017 unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
3027 (with a <code>longjmp</code>).
3032 equivalent to this Lua code:
3049 Note that the code above is "balanced":
3057 <hr><h3><a name="lua_callk"><code>lua_callk</code></a></h3><p>
3063 This function behaves exactly like <a href="#lua_call"><code>lua_call</code></a>,
3070 <hr><h3><a name="lua_CFunction"><code>lua_CFunction</code></a></h3>
3084 <code>lua_gettop(L)</code> returns the number of arguments received by the function.
3086 and its last argument is at index <code>lua_gettop(L)</code>.
3121 <hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
3126 Ensures that there are at least <code>extra</code> free stack slots in the stack.
3139 <hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
3157 <hr><h3><a name="lua_compare"><code>lua_compare</code></a></h3><p>
3163 Returns 1 if the value at index <code>index1</code> satisfies <code>op</code>
3164 when compared with the value at index <code>index2</code>,
3172 The value of <code>op</code> must be one of the following constants:
3176 <li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>: </b> compares for equality (<code>==</code
3177 <li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>: </b> compares for less than (<code>&lt;</c…
3178 <li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code>&lt…
3185 <hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
3190 Concatenates the <code>n</code> values at the top of the stack,
3192 If <code>n</code>&nbsp;is&nbsp;1, the result is the single value on the stack
3194 if <code>n</code> is 0, the result is the empty string.
3202 <hr><h3><a name="lua_copy"><code>lua_copy</code></a></h3><p>
3207 Moves the element at index <code>fromidx</code>
3208 into the valid index <code>toidx</code>
3216 <hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
3222 Parameter <code>narr</code> is a hint for how many elements the table
3224 parameter <code>nrec</code> is a hint for how many other elements
3229 Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</code></a>.
3235 <hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
3246 <a href="#lua_dump"><code>lua_dump</code></a> calls function <code>writer</code> (see <a href="#lua…
3247 with the given <code>data</code>
3252 The value returned is the error code returned by the last
3264 <hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
3274 (see <a href="#luaL_error"><code>luaL_error</code></a>).
3280 <hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
3290 according to the value of the parameter <code>what</code>:
3294 <li><b><code>LUA_GCSTOP</code>: </b>
3298 <li><b><code>LUA_GCRESTART</code>: </b>
3302 <li><b><code>LUA_GCCOLLECT</code>: </b>
3306 <li><b><code>LUA_GCCOUNT</code>: </b>
3310 <li><b><code>LUA_GCCOUNTB</code>: </b>
3315 <li><b><code>LUA_GCSTEP</code>: </b>
3317 The step "size" is controlled by <code>data</code>
3320 you must experimentally tune the value of <code>data</code>.
3325 <li><b><code>LUA_GCSETPAUSE</code>: </b>
3326 sets <code>data</code> as the new value
3331 <li><b><code>LUA_GCSETSTEPMUL</code>: </b>
3332 sets <code>data</code> as the new value for the <em>step multiplier</em> of
3337 <li><b><code>LUA_GCISRUNNING</code>: </b>
3342 <li><b><code>LUA_GCGEN</code>: </b>
3347 <li><b><code>LUA_GCINC</code>: </b>
3356 see <a href="#pdf-collectgarbage"><code>collectgarbage</code></a>.
3362 <hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
3368 If <code>ud</code> is not <code>NULL</code>, Lua stores in <code>*ud</code> the
3369 opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.
3375 <hr><h3><a name="lua_getctx"><code>lua_getctx</code></a></h3><p>
3386 <a href="#lua_getctx"><code>lua_getctx</code></a> always returns <a href="#pdf-LUA_OK"><code>LUA_OK…
3387 and does not change the value of its argument <code>ctx</code>.
3389 <a href="#lua_getctx"><code>lua_getctx</code></a> returns <a href="#pdf-LUA_YIELD"><code>LUA_YIELD<…
3390 the value of <code>ctx</code> to be the context information
3391 (the value passed as the <code>ctx</code> argument
3396 When the callee is <a href="#lua_pcallk"><code>lua_pcallk</code></a>,
3399 That is, upon an error in the function called by <a href="#lua_pcallk"><code>lua_pcallk</code></a>,
3402 In that case, a call to <a href="#lua_getctx"><code>lua_getctx</code></a> will return the error code
3403 (the value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>);
3404 the value of <code>ctx</code> will be set to the context information,
3411 <hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
3416 Pushes onto the stack the value <code>t[k]</code>,
3417 where <code>t</code> is the value at the given index.
3425 <hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
3430 Pushes onto the stack the value of the global <code>name</code>.
3436 <hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
3449 <hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
3454 Pushes onto the stack the value <code>t[k]</code>,
3455 where <code>t</code> is the value at the given index
3456 and <code>k</code> is the value at the top of the stack.
3469 <hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
3483 <hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p>
3496 <hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
3510 <hr><h3><a name="lua_Integer"><code>lua_Integer</code></a></h3>
3518 By default it is a <code>ptrdiff_t</code>,
3526 <hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
3538 <hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
3550 <hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
3562 <hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
3574 <hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
3586 <hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
3598 <hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
3611 <hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
3624 <hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
3637 <hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
3649 <hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
3661 <hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
3673 <hr><h3><a name="lua_len"><code>lua_len</code></a></h3><p>
3679 it is equivalent to the '<code>#</code>' operator in Lua (see <a href="#3.4.6">&sect;3.4.6</a>).
3686 <hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
3697 <code>lua_load</code> pushes the compiled chunk as a Lua
3703 The return values of <code>lua_load</code> are:
3707 <li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a>: </b> no errors;</li>
3709 <li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>: </b>
3712 <li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
3715 <li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
3716 error while running a <code>__gc</code> metamethod.
3724 The <code>lua_load</code> function uses a user-supplied <code>reader</code> function
3725 to read the chunk (see <a href="#lua_Reader"><code>lua_Reader</code></a>).
3726 The <code>data</code> argument is an opaque value passed to the reader function.
3730 The <code>source</code> argument gives a name to the chunk,
3735 <code>lua_load</code> automatically detects whether the chunk is text or binary
3736 and loads it accordingly (see program <code>luac</code>).
3737 The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>,
3739 a <code>NULL</code> value is equivalent to the string "<code>bt</code>".
3743 <code>lua_load</code> uses the stack internally,
3751 stored at index <code>LUA_RIDX_GLOBALS</code> in the registry (see <a href="#4.5">&sect;4.5</a>).
3753 this upvalue will be the <code>_ENV</code> variable (see <a href="#2.2">&sect;2.2</a>).
3759 <hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
3765 Returns <code>NULL</code> if cannot create the thread or the state
3767 The argument <code>f</code> is the allocator function;
3769 The second argument, <code>ud</code>, is an opaque pointer that Lua
3776 <hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
3782 It is equivalent to <code>lua_createtable(L, 0, 0)</code>.
3788 <hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
3794 and returns a pointer to a <a href="#lua_State"><code>lua_State</code></a> that represents this new…
3809 <hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
3823 <hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
3832 then <a href="#lua_next"><code>lua_next</code></a> returns 0 (and pushes nothing).
3853 do not call <a href="#lua_tolstring"><code>lua_tolstring</code></a> directly on a key,
3855 Recall that <a href="#lua_tolstring"><code>lua_tolstring</code></a> may change
3857 this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
3861 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
3868 <hr><h3><a name="lua_Number"><code>lua_Number</code></a></h3>
3873 By default, it is double, but that can be changed in <code>luaconf.h</code>.
3881 <hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
3890 Both <code>nargs</code> and <code>nresults</code> have the same meaning as
3891 in <a href="#lua_call"><code>lua_call</code></a>.
3893 <a href="#lua_pcall"><code>lua_pcall</code></a> behaves exactly like <a href="#lua_call"><code>lua_…
3895 <a href="#lua_pcall"><code>lua_pcall</code></a> catches it,
3897 and returns an error code.
3898 Like <a href="#lua_call"><code>lua_call</code></a>,
3899 <a href="#lua_pcall"><code>lua_pcall</code></a> always removes the function
3904 If <code>msgh</code> is 0,
3907 Otherwise, <code>msgh</code> is the stack index of a
3913 returned on the stack by <a href="#lua_pcall"><code>lua_pcall</code></a>.
3919 Such information cannot be gathered after the return of <a href="#lua_pcall"><code>lua_pcall</code>…
3924 The <a href="#lua_pcall"><code>lua_pcall</code></a> function returns one of the following codes
3925 (defined in <code>lua.h</code>):
3929 <li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b>
3932 <li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>: </b>
3936 <li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
3941 <li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>: </b>
3945 <li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
3946 error while running a <code>__gc</code> metamethod.
3956 <hr><h3><a name="lua_pcallk"><code>lua_pcallk</code></a></h3><p>
3966 This function behaves exactly like <a href="#lua_pcall"><code>lua_pcall</code></a>,
3973 <hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
3978 Pops <code>n</code> elements from the stack.
3984 <hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
3989 Pushes a boolean value with value <code>b</code> onto the stack.
3995 <hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
4011 Then <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a>
4013 with the argument <code>n</code> telling how many values should be
4015 <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.
4019 The maximum value for <code>n</code> is 255.
4023 When <code>n</code> is zero,
4032 <hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
4039 and pushes onto the stack a Lua value of type <code>function</code> that,
4046 and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
4050 <code>lua_pushcfunction</code> is defined as a macro:
4055 Note that <code>f</code> is used twice.
4061 <hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
4068 It is similar to the ANSI&nbsp;C function <code>sprintf</code>,
4083 '<code>%%</code>' (inserts a '<code>%</code>' in the string),
4084 '<code>%s</code>' (inserts a zero-terminated string, with no size restrictions),
4085 '<code>%f</code>' (inserts a <a href="#lua_Number"><code>lua_Number</code></a>),
4086 '<code>%p</code>' (inserts a pointer as a hexadecimal numeral),
4087 '<code>%d</code>' (inserts an <code>int</code>), and
4088 '<code>%c</code>' (inserts an <code>int</code> as a byte).
4096 <hr><h3><a name="lua_pushglobaltable"><code>lua_pushglobaltable</code></a></h3><p>
4107 <hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
4112 Pushes a number with value <code>n</code> onto the stack.
4118 <hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
4128 A <em>light userdata</em> represents a pointer, a <code>void*</code>.
4139 <hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
4144 This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,
4145 but can be used only when <code>s</code> is a literal string.
4152 <hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
4157 Pushes the string pointed to by <code>s</code> with size <code>len</code>
4160 so the memory at <code>s</code> can be freed or reused immediately after
4173 <hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
4184 <hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
4189 Pushes a number with value <code>n</code> onto the stack.
4195 <hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
4200 Pushes the zero-terminated string pointed to by <code>s</code>
4203 so the memory at <code>s</code> can be freed or reused immediately after
4212 If <code>s</code> is <code>NULL</code>, pushes <b>nil</b> and returns <code>NULL</code>.
4218 <hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
4223 Pushes the thread represented by <code>L</code> onto the stack.
4230 <hr><h3><a name="lua_pushunsigned"><code>lua_pushunsigned</code></a></h3><p>
4235 Pushes a number with value <code>n</code> onto the stack.
4241 <hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
4253 <hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
4260 …alent to <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>, except that it receives a <c…
4267 <hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
4272 Returns 1 if the two values in indices <code>index1</code> and
4273 <code>index2</code> are primitively equal
4282 <hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
4287 Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw access
4294 <hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
4299 Pushes onto the stack the value <code>t[n]</code>,
4300 where <code>t</code> is the table at the given index.
4308 <hr><h3><a name="lua_rawgetp"><code>lua_rawgetp</code></a></h3><p>
4313 Pushes onto the stack the value <code>t[k]</code>,
4314 where <code>t</code> is the table at the given index and
4315 <code>k</code> is the pointer <code>p</code> represented as a light userdata.
4323 <hr><h3><a name="lua_rawlen"><code>lua_rawlen</code></a></h3><p>
4330 for tables, this is the result of the length operator ('<code>#</code>')
4340 <hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
4345 Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw assignment
4352 <hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
4357 Does the equivalent of <code>t[n] = v</code>,
4358 where <code>t</code> is the table at the given index
4359 and <code>v</code> is the value at the top of the stack.
4371 <hr><h3><a name="lua_rawsetp"><code>lua_rawsetp</code></a></h3><p>
4376 Does the equivalent of <code>t[k] = v</code>,
4377 where <code>t</code> is the table at the given index,
4378 <code>k</code> is the pointer <code>p</code> represented as a light userdata,
4379 and <code>v</code> is the value at the top of the stack.
4391 <hr><h3><a name="lua_Reader"><code>lua_Reader</code></a></h3>
4397 The reader function used by <a href="#lua_load"><code>lua_load</code></a>.
4399 <a href="#lua_load"><code>lua_load</code></a> calls the reader,
4400 passing along its <code>data</code> parameter.
4403 and set <code>size</code> to the block size.
4406 the reader must return <code>NULL</code> or set <code>size</code> to zero.
4413 <hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
4418 Sets the C function <code>f</code> as the new value of global <code>name</code>.
4429 <hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
4443 <hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
4457 <hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
4468 then you call <a href="#lua_resume"><code>lua_resume</code></a>,
4469 with <code>nargs</code> being the number of arguments.
4471 When it returns, the stack contains all values passed to <a href="#lua_yield"><code>lua_yield</code
4473 <a href="#lua_resume"><code>lua_resume</code></a> returns
4474 <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the coroutine yields,
4475 <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> if the coroutine finishes its execution
4477 or an error code in case of errors (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
4489 you remove any results from the last <a href="#lua_yield"><code>lua_yield</code></a>,
4491 be passed as results from <code>yield</code>,
4492 and then call <a href="#lua_resume"><code>lua_resume</code></a>.
4496 The parameter <code>from</code> represents the coroutine that is resuming <code>L</code>.
4498 this parameter can be <code>NULL</code>.
4504 <hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
4509 Changes the allocator function of a given state to <code>f</code>
4510 with user data <code>ud</code>.
4516 <hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
4521 Does the equivalent to <code>t[k] = v</code>,
4522 where <code>t</code> is the value at the given index
4523 and <code>v</code> is the value at the top of the stack.
4535 <hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
4541 sets it as the new value of global <code>name</code>.
4547 <hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
4559 <hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
4564 Does the equivalent to <code>t[k] = v</code>,
4565 where <code>t</code> is the value at the given index,
4566 <code>v</code> is the value at the top of the stack,
4567 and <code>k</code> is the value just below the top.
4579 <hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
4588 If <code>index</code> is&nbsp;0, then all stack elements are removed.
4594 <hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p>
4606 <hr><h3><a name="lua_State"><code>lua_State</code></a></h3>
4619 every function in the library, except to <a href="#lua_newstate"><code>lua_newstate</code></a>,
4626 <hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
4631 Returns the status of the thread <code>L</code>.
4635 The status can be 0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) for a normal thread,
4636 an error code if the thread finished the execution
4637 of a <a href="#lua_resume"><code>lua_resume</code></a> with an error,
4638 or <a name="pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the thread is suspended.
4642 You can only call functions in threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>.
4643 You can resume threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>
4644 (to start a new coroutine) or <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a>
4651 <hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
4659 <a href="#lua_toboolean"><code>lua_toboolean</code></a> returns true for any Lua value
4663 use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's type.)
4669 <hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
4676 otherwise, returns <code>NULL</code>.
4682 <hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
4687 …alent to <a href="#lua_tointegerx"><code>lua_tointegerx</code></a> with <code>isnum</code> equal t…
4693 <hr><h3><a name="lua_tointegerx"><code>lua_tointegerx</code></a></h3><p>
4699 to the signed integral type <a href="#lua_Integer"><code>lua_Integer</code></a>.
4702 otherwise, <code>lua_tointegerx</code> returns&nbsp;0.
4711 If <code>isnum</code> is not <code>NULL</code>,
4719 <hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
4725 If <code>len</code> is not <code>NULL</code>,
4726 it also sets <code>*len</code> with the string length.
4728 otherwise, the function returns <code>NULL</code>.
4730 then <code>lua_tolstring</code> also
4732 (This change confuses <a href="#lua_next"><code>lua_next</code></a>
4733 when <code>lua_tolstring</code> is applied to keys during a table traversal.)
4737 <code>lua_tolstring</code> returns a fully aligned pointer
4739 This string always has a zero ('<code>\0</code>')
4743 there is no guarantee that the pointer returned by <code>lua_tolstring</code>
4750 <hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
4755 …ivalent to <a href="#lua_tonumberx"><code>lua_tonumberx</code></a> with <code>isnum</code> equal t…
4761 <hr><h3><a name="lua_tonumberx"><code>lua_tonumberx</code></a></h3><p>
4767 …he C&nbsp;type <a href="#lua_Number"><code>lua_Number</code></a> (see <a href="#lua_Number"><code>…
4770 otherwise, <a href="#lua_tonumberx"><code>lua_tonumberx</code></a> returns&nbsp;0.
4774 If <code>isnum</code> is not <code>NULL</code>,
4782 <hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
4788 C&nbsp;pointer (<code>void*</code>).
4790 otherwise, <code>lua_topointer</code> returns <code>NULL</code>.
4802 <hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
4807 …uivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to…
4813 <hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
4819 (represented as <code>lua_State*</code>).
4821 otherwise, the function returns <code>NULL</code>.
4827 <hr><h3><a name="lua_tounsigned"><code>lua_tounsigned</code></a></h3><p>
4832 …lent to <a href="#lua_tounsignedx"><code>lua_tounsignedx</code></a> with <code>isnum</code> equal …
4838 <hr><h3><a name="lua_tounsignedx"><code>lua_tounsignedx</code></a></h3><p>
4844 to the unsigned integral type <a href="#lua_Unsigned"><code>lua_Unsigned</code></a>.
4847 otherwise, <code>lua_tounsignedx</code> returns&nbsp;0.
4859 If <code>isnum</code> is not <code>NULL</code>,
4867 <hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
4876 Otherwise, returns <code>NULL</code>.
4882 <hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
4888 or <code>LUA_TNONE</code> for a non-valid (but acceptable) index.
4889 The types returned by <a href="#lua_type"><code>lua_type</code></a> are coded by the following cons…
4890 defined in <code>lua.h</code>:
4891 <a name="pdf-LUA_TNIL"><code>LUA_TNIL</code></a>,
4892 <a name="pdf-LUA_TNUMBER"><code>LUA_TNUMBER</code></a>,
4893 <a name="pdf-LUA_TBOOLEAN"><code>LUA_TBOOLEAN</code></a>,
4894 <a name="pdf-LUA_TSTRING"><code>LUA_TSTRING</code></a>,
4895 <a name="pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>,
4896 <a name="pdf-LUA_TFUNCTION"><code>LUA_TFUNCTION</code></a>,
4897 <a name="pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>,
4898 <a name="pdf-LUA_TTHREAD"><code>LUA_TTHREAD</code></a>,
4900 <a name="pdf-LUA_TLIGHTUSERDATA"><code>LUA_TLIGHTUSERDATA</code></a>.
4906 <hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
4911 Returns the name of the type encoded by the value <code>tp</code>,
4912 which must be one the values returned by <a href="#lua_type"><code>lua_type</code></a>.
4918 <hr><h3><a name="lua_Unsigned"><code>lua_Unsigned</code></a></h3>
4927 By default it is an <code>unsigned int</code> or an <code>unsigned long</code>,
4934 <hr><h3><a name="lua_upvalueindex"><code>lua_upvalueindex</code></a></h3><p>
4939 Returns the pseudo-index that represents the <code>i</code>-th upvalue of
4946 <hr><h3><a name="lua_version"><code>lua_version</code></a></h3><p>
4952 When called with a valid <a href="#lua_State"><code>lua_State</code></a>,
4954 When called with <code>NULL</code>,
4961 <hr><h3><a name="lua_Writer"><code>lua_Writer</code></a></h3>
4968 The type of the writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
4970 <a href="#lua_dump"><code>lua_dump</code></a> calls the writer,
4971 passing along the buffer to be written (<code>p</code>),
4972 its size (<code>sz</code>),
4973 and the <code>data</code> parameter supplied to <a href="#lua_dump"><code>lua_dump</code></a>.
4977 The writer returns an error code:
4979 any other value means an error and stops <a href="#lua_dump"><code>lua_dump</code></a> from
4986 <hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
4995 This function pops <code>n</code> values from the stack <code>from</code>,
4996 and pushes them onto the stack <code>to</code>.
5002 <hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
5007 This function is equivalent to <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
5011 the function calling <code>lua_yield</code>.
5017 <hr><h3><a name="lua_yieldk"><code>lua_yieldk</code></a></h3><p>
5032 When a C&nbsp;function calls <a href="#lua_yieldk"><code>lua_yieldk</code></a> in that way,
5034 and the call to <a href="#lua_resume"><code>lua_resume</code></a> that started this coroutine retur…
5035 The parameter <code>nresults</code> is the number of values from the stack
5036 that are passed as results to <a href="#lua_resume"><code>lua_resume</code></a>.
5041 Lua calls the given continuation function <code>k</code> to continue
5046 replaced by the arguments passed to <a href="#lua_resume"><code>lua_resume</code></a>.
5048 the continuation function may access the value <code>ctx</code>
5049 by calling <a href="#lua_getctx"><code>lua_getctx</code></a>.
5069 <hr><h3><a name="lua_Debug"><code>lua_Debug</code></a></h3>
5091 <a href="#lua_getstack"><code>lua_getstack</code></a> fills only the private part
5093 To fill the other fields of <a href="#lua_Debug"><code>lua_Debug</code></a> with useful information,
5094 call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
5098 The fields of <a href="#lua_Debug"><code>lua_Debug</code></a> have the following meaning:
5102 <li><b><code>source</code>: </b>
5104 If <code>source</code> starts with a '<code>@</code>',
5106 the file name follows the '<code>@</code>'.
5107 If <code>source</code> starts with a '<code>=</code>',
5111 <code>source</code> is that string.
5114 <li><b><code>short_src</code>: </b>
5115 a "printable" version of <code>source</code>, to be used in error messages.
5118 <li><b><code>linedefined</code>: </b>
5122 <li><b><code>lastlinedefined</code>: </b>
5126 <li><b><code>what</code>: </b>
5127 the string <code>"Lua"</code> if the function is a Lua function,
5128 <code>"C"</code> if it is a C&nbsp;function,
5129 <code>"main"</code> if it is the main part of a chunk.
5132 <li><b><code>currentline</code>: </b>
5135 <code>currentline</code> is set to -1.
5138 <li><b><code>name</code>: </b>
5144 The <code>lua_getinfo</code> function checks how the function was
5147 then <code>name</code> is set to <code>NULL</code>.
5150 <li><b><code>namewhat</code>: </b>
5151 explains the <code>name</code> field.
5152 The value of <code>namewhat</code> can be
5153 <code>"global"</code>, <code>"local"</code>, <code>"method"</code>,
5154 <code>"field"</code>, <code>"upvalue"</code>, or <code>""</code> (the empty string),
5159 <li><b><code>istailcall</code>: </b>
5164 <li><b><code>nups</code>: </b>
5168 <li><b><code>nparams</code>: </b>
5173 <li><b><code>isvararg</code>: </b>
5183 <hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
5194 <hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
5205 <hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
5216 <hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
5226 the parameter <code>ar</code> must be a valid activation record that was
5227 filled by a previous call to <a href="#lua_getstack"><code>lua_getstack</code></a> or
5228 given as argument to a hook (see <a href="#lua_Hook"><code>lua_Hook</code></a>).
5233 and start the <code>what</code> string with the character '<code>&gt;</code>'.
5235 <code>lua_getinfo</code> pops the function from the top of the stack.)
5236 For instance, to know in which line a function <code>f</code> was defined,
5237 you can write the following code:
5247 Each character in the string <code>what</code>
5248 selects some fields of the structure <code>ar</code> to be filled or
5253 <li><b>'<code>n</code>': </b> fills in the field <code>name</code> and <code>namewhat</code>;
5256 <li><b>'<code>S</code>': </b>
5257 fills in the fields <code>source</code>, <code>short_src</code>,
5258 <code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;
5261 <li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>;
5264 <li><b>'<code>t</code>': </b> fills in the field <code>istailcall</code>;
5267 <li><b>'<code>u</code>': </b> fills in the fields
5268 <code>nups</code>, <code>nparams</code>, and <code>isvararg</code>;
5271 <li><b>'<code>f</code>': </b>
5276 <li><b>'<code>L</code>': </b>
5279 (A <em>valid line</em> is a line with some associated code,
5288 (for instance, an invalid option in <code>what</code>).
5294 <hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
5305 the parameter <code>ar</code> must be a valid activation record that was
5306 filled by a previous call to <a href="#lua_getstack"><code>lua_getstack</code></a> or
5307 given as argument to a hook (see <a href="#lua_Hook"><code>lua_Hook</code></a>).
5308 The index <code>n</code> selects which local variable to inspect;
5309 see <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for details about variable indices
5314 <a href="#lua_getlocal"><code>lua_getlocal</code></a> pushes the variable's value onto the stack
5319 In the second case, <code>ar</code> should be <code>NULL</code> and the function
5327 Returns <code>NULL</code> (and pushes nothing)
5335 <hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
5344 This function fills parts of a <a href="#lua_Debug"><code>lua_Debug</code></a> structure with
5350 When there are no errors, <a href="#lua_getstack"><code>lua_getstack</code></a> returns 1;
5358 <hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
5367 <a href="#lua_getupvalue"><code>lua_getupvalue</code></a> gets the index <code>n</code> of an upval…
5370 <code>funcindex</code> points to the closure in the stack.
5377 Returns <code>NULL</code> (and pushes nothing)
5379 For C&nbsp;functions, this function uses the empty string <code>""</code>
5386 <hr><h3><a name="lua_Hook"><code>lua_Hook</code></a></h3>
5394 Whenever a hook is called, its <code>ar</code> argument has its field
5395 <code>event</code> set to the specific event that triggered the hook.
5397 <a name="pdf-LUA_HOOKCALL"><code>LUA_HOOKCALL</code></a>, <a name="pdf-LUA_HOOKRET"><code>LUA_HOOKR…
5398 <a name="pdf-LUA_HOOKTAILCALL"><code>LUA_HOOKTAILCALL</code></a>, <a name="pdf-LUA_HOOKLINE"><code>…
5399 and <a name="pdf-LUA_HOOKCOUNT"><code>LUA_HOOKCOUNT</code></a>.
5400 Moreover, for line events, the field <code>currentline</code> is also set.
5401 To get the value of any other field in <code>ar</code>,
5402 the hook must call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
5406 For call events, <code>event</code> can be <code>LUA_HOOKCALL</code>,
5407 the normal value, or <code>LUA_HOOKTAILCALL</code>, for a tail call;
5419 that is, they cannot call <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
5420 …a href="#lua_pcallk"><code>lua_pcallk</code></a>, or <a href="#lua_callk"><code>lua_callk</code></…
5428 calling <a href="#lua_yield"><code>lua_yield</code></a> with <code>nresults</code> equal to zero.
5434 <hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
5443 Argument <code>f</code> is the hook function.
5444 <code>mask</code> specifies on which events the hook will be called:
5446 <a name="pdf-LUA_MASKCALL"><code>LUA_MASKCALL</code></a>,
5447 <a name="pdf-LUA_MASKRET"><code>LUA_MASKRET</code></a>,
5448 <a name="pdf-LUA_MASKLINE"><code>LUA_MASKLINE</code></a>,
5449 and <a name="pdf-LUA_MASKCOUNT"><code>LUA_MASKCOUNT</code></a>.
5450 The <code>count</code> argument is only meaningful when the mask
5451 includes <code>LUA_MASKCOUNT</code>.
5468 start the execution of a new line of code,
5469 or when it jumps back in the code (even to the same line).
5474 <code>count</code> instructions.
5481 A hook is disabled by setting <code>mask</code> to zero.
5487 <hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
5493 Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal<…
5494 (see <a href="#lua_getlocal"><code>lua_getlocal</code></a>).
5495 <a href="#lua_setlocal"><code>lua_setlocal</code></a> assigns the value at the top of the stack
5501 Returns <code>NULL</code> (and pops nothing)
5509 <hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
5518 Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>…
5519 (see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>).
5523 Returns <code>NULL</code> (and pops nothing)
5530 <hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p>
5535 Returns an unique identifier for the upvalue numbered <code>n</code>
5536 from the closure at index <code>funcindex</code>.
5537 Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>…
5538 (see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>)
5539 (but <code>n</code> cannot be greater than the number of upvalues).
5553 <hr><h3><a name="lua_upvaluejoin"><code>lua_upvaluejoin</code></a></h3><p>
5559 Make the <code>n1</code>-th upvalue of the Lua closure at index <code>funcindex1</code>
5560 refer to the <code>n2</code>-th upvalue of the Lua closure at index <code>funcindex2</code>.
5582 are defined in header file <code>lauxlib.h</code> and
5583 have a prefix <code>luaL_</code>.
5591 more consistency to your code.
5606 (e.g., "<code>bad argument #1</code>"),
5611 Functions called <code>luaL_check*</code>
5624 <hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
5629 Adds the byte <code>c</code> to the buffer <code>B</code>
5630 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5636 <hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
5641 Adds the string pointed to by <code>s</code> with length <code>l</code> to
5642 the buffer <code>B</code>
5643 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5650 <hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
5655 Adds to the buffer <code>B</code> (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>)
5656 a string of length <code>n</code> previously copied to the
5657 buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>).
5663 <hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
5668 Adds the zero-terminated string pointed to by <code>s</code>
5669 to the buffer <code>B</code>
5670 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5677 <hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
5683 to the buffer <code>B</code>
5684 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5697 <hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
5705 Checks whether <code>cond</code> is true.
5712 <hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
5718 that includes <code>extramsg</code> as a comment.
5724 as <code>return luaL_argerror(<em>args</em>)</code>.
5730 <hr><h3><a name="luaL_Buffer"><code>luaL_Buffer</code></a></h3>
5738 A string buffer allows C&nbsp;code to build Lua strings piecemeal.
5743 <li>First declare a variable <code>b</code> of type <a href="#luaL_Buffer"><code>luaL_Buffer</code>…
5745 <li>Then initialize it with a call <code>luaL_buffinit(L, &amp;b)</code>.</li>
5749 the <code>luaL_add*</code> functions.
5753 Finish by calling <code>luaL_pushresult(&amp;b)</code>.
5765 <li>First declare a variable <code>b</code> of type <a href="#luaL_Buffer"><code>luaL_Buffer</code>…
5768 size <code>sz</code> with a call <code>luaL_buffinitsize(L, &amp;b, sz)</code>.</li>
5773 Finish by calling <code>luaL_pushresultsize(&amp;b, sz)</code>,
5774 where <code>sz</code> is the total size of the resulting string
5791 (The only exception to this rule is <a href="#luaL_addvalue"><code>luaL_addvalue</code></a>.)
5792 After calling <a href="#luaL_pushresult"><code>luaL_pushresult</code></a> the stack is back to its
5800 <hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
5805 Initializes a buffer <code>B</code>.
5808 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5814 <hr><h3><a name="luaL_buffinitsize"><code>luaL_buffinitsize</code></a></h3><p>
5820 <a href="#luaL_buffinit"><code>luaL_buffinit</code></a>, <a href="#luaL_prepbuffsize"><code>luaL_pr…
5826 <hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
5835 If the object at index <code>obj</code> has a metatable and this
5836 metatable has a field <code>e</code>,
5847 <hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
5853 of any type (including <b>nil</b>) at position <code>arg</code>.
5859 <hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3><p>
5864 Checks whether the function argument <code>arg</code> is a number
5865 and returns this number cast to an <code>int</code>.
5871 <hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
5876 Checks whether the function argument <code>arg</code> is a number
5877 and returns this number cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.
5883 <hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3><p>
5888 Checks whether the function argument <code>arg</code> is a number
5889 and returns this number cast to a <code>long</code>.
5895 <hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
5900 Checks whether the function argument <code>arg</code> is a string
5902 if <code>l</code> is not <code>NULL</code> fills <code>*l</code>
5907 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
5914 <hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
5919 Checks whether the function argument <code>arg</code> is a number
5926 <hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
5934 Checks whether the function argument <code>arg</code> is a string and
5935 searches for this string in the array <code>lst</code>
5943 If <code>def</code> is not <code>NULL</code>,
5944 the function uses <code>def</code> as a default value when
5945 there is no argument <code>arg</code> or when this argument is <b>nil</b>.
5957 <hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
5962 Grows the stack size to <code>top + sz</code> elements,
5964 <code>msg</code> is an additional text to go into the error message
5965 (or <code>NULL</code> for no additional text).
5971 <hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
5976 Checks whether the function argument <code>arg</code> is a string
5981 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
5988 <hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
5993 Checks whether the function argument <code>arg</code> has type <code>t</code>.
5994 See <a href="#lua_type"><code>lua_type</code></a> for the encoding of types for <code>t</code>.
6000 <hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
6005 Checks whether the function argument <code>arg</code> is a userdata
6006 of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>…
6007 returns the userdata address (see <a href="#lua_touserdata"><code>lua_touserdata</code></a>).
6013 <hr><h3><a name="luaL_checkunsigned"><code>luaL_checkunsigned</code></a></h3><p>
6018 Checks whether the function argument <code>arg</code> is a number
6019 and returns this number cast to a <a href="#lua_Unsigned"><code>lua_Unsigned</code></a>.
6025 <hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p>
6032 and the code making the call are all using the same version of Lua.
6041 <hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
6059 <hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
6077 <hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
6083 The error message format is given by <code>fmt</code>
6085 following the same rules of <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>.
6094 as <code>return luaL_error(<em>args</em>)</code>.
6100 <hr><h3><a name="luaL_execresult"><code>luaL_execresult</code></a></h3><p>
6107 (<a href="#pdf-os.execute"><code>os.execute</code></a> and <a href="#pdf-io.close"><code>io.close</
6113 <hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>
6120 …pdf-io.open"><code>io.open</code></a>, <a href="#pdf-os.rename"><code>os.rename</code></a>, <a hre…
6126 <hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
6131 Pushes onto the stack the field <code>e</code> from the metatable
6132 of the object at index <code>obj</code>.
6141 <hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
6146 Pushes onto the stack the metatable associated with name <code>tname</code>
6147 in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
6153 <hr><h3><a name="luaL_getsubtable"><code>luaL_getsubtable</code></a></h3><p>
6158 Ensures that the value <code>t[fname]</code>,
6159 where <code>t</code> is the value at index <code>idx</code>,
6169 <hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
6177 Creates a copy of string <code>s</code> by replacing
6178 any occurrence of the string <code>p</code>
6179 with the string <code>r</code>.
6186 <hr><h3><a name="luaL_len"><code>luaL_len</code></a></h3><p>
6193 it is equivalent to the '<code>#</code>' operator in Lua (see <a href="#3.4.6">&sect;3.4.6</a>).
6201 <hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
6209 …ent to <a href="#luaL_loadbufferx"><code>luaL_loadbufferx</code></a> with <code>mode</code> equal …
6215 <hr><h3><a name="luaL_loadbufferx"><code>luaL_loadbufferx</code></a></h3><p>
6225 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the
6226 buffer pointed to by <code>buff</code> with size <code>sz</code>.
6230 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
6231 <code>name</code> is the chunk name,
6233 The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>.
6239 <hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
6244 …valent to <a href="#luaL_loadfilex"><code>luaL_loadfilex</code></a> with <code>mode</code> equal t…
6250 <hr><h3><a name="luaL_loadfilex"><code>luaL_loadfilex</code></a></h3><p>
6257 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the file
6258 named <code>filename</code>.
6259 If <code>filename</code> is <code>NULL</code>,
6261 The first line in the file is ignored if it starts with a <code>#</code>.
6265 The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>.
6269 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>,
6270 but it has an extra error code <a name="pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a>
6275 As <a href="#lua_load"><code>lua_load</code></a>, this function only loads the chunk;
6282 <hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
6288 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in
6289 the zero-terminated string <code>s</code>.
6293 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
6297 Also as <a href="#lua_load"><code>lua_load</code></a>, this function only loads the chunk;
6304 <hr><h3><a name="luaL_newlib"><code>luaL_newlib</code></a></h3><p>
6310 the functions in list <code>l</code>.
6320 <hr><h3><a name="luaL_newlibtable"><code>luaL_newlibtable</code></a></h3><p>
6326 to store all entries in the array <code>l</code>
6328 It is intended to be used in conjunction with <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></…
6329 (see <a href="#luaL_newlib"><code>luaL_newlib</code></a>).
6334 The array <code>l</code> must be the actual array,
6341 <hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
6346 If the registry already has the key <code>tname</code>,
6350 adds it to the registry with key <code>tname</code>,
6356 with <code>tname</code> in the registry.
6362 <hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
6368 It calls <a href="#lua_newstate"><code>lua_newstate</code></a> with an
6369 allocator based on the standard&nbsp;C <code>realloc</code> function
6377 or <code>NULL</code> if there is a memory allocation error.
6383 <hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
6394 <hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3><p>
6399 If the function argument <code>arg</code> is a number,
6400 returns this number cast to an <code>int</code>.
6402 returns <code>d</code>.
6409 <hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
6416 If the function argument <code>arg</code> is a number,
6417 returns this number cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.
6419 returns <code>d</code>.
6426 <hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3><p>
6431 If the function argument <code>arg</code> is a number,
6432 returns this number cast to a <code>long</code>.
6434 returns <code>d</code>.
6441 <hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
6449 If the function argument <code>arg</code> is a string,
6452 returns <code>d</code>.
6457 If <code>l</code> is not <code>NULL</code>,
6458 fills the position <code>*l</code> with the result's length.
6464 <hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
6469 If the function argument <code>arg</code> is a number,
6472 returns <code>d</code>.
6479 <hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
6486 If the function argument <code>arg</code> is a string,
6489 returns <code>d</code>.
6496 <hr><h3><a name="luaL_optunsigned"><code>luaL_optunsigned</code></a></h3><p>
6503 If the function argument <code>arg</code> is a number,
6504 returns this number cast to a <a href="#lua_Unsigned"><code>lua_Unsigned</code></a>.
6506 returns <code>u</code>.
6513 <hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
6518 Equivalent to <a href="#luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a>
6519 with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
6525 <hr><h3><a name="luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a></h3><p>
6530 Returns an address to a space of size <code>sz</code>
6531 where you can copy a string to be added to buffer <code>B</code>
6532 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6534 <a href="#luaL_addsize"><code>luaL_addsize</code></a> with the size of the string to actually add
6541 <hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
6546 Finishes the use of buffer <code>B</code> leaving the final string on
6553 <hr><h3><a name="luaL_pushresultsize"><code>luaL_pushresultsize</code></a></h3><p>
6558 …sequence <a href="#luaL_addsize"><code>luaL_addsize</code></a>, <a href="#luaL_pushresult"><code>l…
6564 <hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
6570 in the table at index <code>t</code>,
6576 As long as you do not manually add integer keys into table <code>t</code>,
6577 <a href="#luaL_ref"><code>luaL_ref</code></a> ensures the uniqueness of the key it returns.
6578 You can retrieve an object referred by reference <code>r</code>
6579 by calling <code>lua_rawgeti(L, t, r)</code>.
6580 Function <a href="#luaL_unref"><code>luaL_unref</code></a> frees a reference and its associated obj…
6585 <a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <a name="pdf-LUA_REFNIL"><code>L…
6586 The constant <a name="pdf-LUA_NOREF"><code>LUA_NOREF</code></a> is guaranteed to be different
6587 from any reference returned by <a href="#luaL_ref"><code>luaL_ref</code></a>.
6593 <hr><h3><a name="luaL_Reg"><code>luaL_Reg</code></a></h3>
6601 <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a>.
6602 <code>name</code> is the function name and <code>func</code> is a pointer to
6604 Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sentinel entry
6605 in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
6611 <hr><h3><a name="luaL_requiref"><code>luaL_requiref</code></a></h3><p>
6617 Calls function <code>openf</code> with string <code>modname</code> as an argument
6618 and sets the call result in <code>package.loaded[modname]</code>,
6619 as if that function has been called through <a href="#pdf-require"><code>require</code></a>.
6623 If <code>glb</code> is true,
6624 also stores the result into global <code>modname</code>.
6634 <hr><h3><a name="luaL_setfuncs"><code>luaL_setfuncs</code></a></h3><p>
6639 Registers all functions in the array <code>l</code>
6640 (see <a href="#luaL_Reg"><code>luaL_Reg</code></a>) into the table on the top of the stack
6645 When <code>nup</code> is not zero,
6646 all functions are created sharing <code>nup</code> upvalues,
6655 <hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
6661 as the metatable associated with name <code>tname</code>
6662 in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
6668 <hr><h3><a name="luaL_testudata"><code>luaL_testudata</code></a></h3><p>
6673 This function works like <a href="#luaL_checkudata"><code>luaL_checkudata</code></a>,
6675 it returns <code>NULL</code> instead of throwing an error.
6681 <hr><h3><a name="luaL_tolstring"><code>luaL_tolstring</code></a></h3><p>
6690 If <code>len</code> is not <code>NULL</code>,
6691 the function also sets <code>*len</code> with the string length.
6695 If the value has a metatable with a <code>"__tostring"</code> field,
6696 then <code>luaL_tolstring</code> calls the corresponding metamethod
6704 <hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p>
6710 Creates and pushes a traceback of the stack <code>L1</code>.
6711 If <code>msg</code> is not <code>NULL</code> it is appended
6713 The <code>level</code> parameter tells at which level
6720 <hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
6731 <hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
6736 Releases reference <code>ref</code> from the table at index <code>t</code>
6737 (see <a href="#luaL_ref"><code>luaL_ref</code></a>).
6740 The reference <code>ref</code> is also freed to be used again.
6744 If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a href="#pdf-LUA_REF…
6745 <a href="#luaL_unref"><code>luaL_unref</code></a> does nothing.
6751 <hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
6757 of the control at level <code>lvl</code> in the call stack.
6783 (e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable…
6787 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
6825 the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> fun…
6829 <a href="#luaL_requiref"><code>luaL_requiref</code></a> to call
6830 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
6831 <a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
6832 <a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),
6833 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
6834 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
6835 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
6836 <a name="pdf-luaopen_bit32"><code>luaopen_bit32</code></a> (for the bit library),
6837 <a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
6838 <a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
6839 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
6840 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
6854 <hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
6856 the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
6858 <code>message</code> is an error message;
6865 <hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>
6870 It performs different functions according to its first argument, <code>opt</code>:
6874 <li><b>"<code>collect</code>": </b>
6879 <li><b>"<code>stop</code>": </b>
6885 <li><b>"<code>restart</code>": </b>
6889 <li><b>"<code>count</code>": </b>
6903 <li><b>"<code>step</code>": </b>
6905 The step "size" is controlled by <code>arg</code>
6908 you must experimentally tune the value of <code>arg</code>.
6912 <li><b>"<code>setpause</code>": </b>
6913 sets <code>arg</code> as the new value for the <em>pause</em> of
6918 <li><b>"<code>setstepmul</code>": </b>
6919 sets <code>arg</code> as the new value for the <em>step multiplier</em> of
6924 <li><b>"<code>isrunning</code>": </b>
6929 <li><b>"<code>generational</code>": </b>
6934 <li><b>"<code>incremental</code>": </b>
6944 <hr><h3><a name="pdf-dofile"><code>dofile ([filename])</code></a></h3>
6947 <code>dofile</code> executes the contents of the standard input (<code>stdin</code>).
6949 In case of errors, <code>dofile</code> propagates the error
6950 to its caller (that is, <code>dofile</code> does not run in protected mode).
6956 <hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
6958 and returns <code>message</code> as the error message.
6959 Function <code>error</code> never returns.
6963 Usually, <code>error</code> adds some information about the error position
6965 The <code>level</code> argument specifies how to get the error position.
6967 <code>error</code> function was called.
6969 that called <code>error</code> was called; and so on.
6977 <hr><h3><a name="pdf-_G"><code>_G</code></a></h3>
6988 <hr><h3><a name="pdf-getmetatable"><code>getmetatable (object)</code></a></h3>
6992 If <code>object</code> does not have a metatable, returns <b>nil</b>.
6994 if the object's metatable has a <code>"__metatable"</code> field,
7002 <hr><h3><a name="pdf-ipairs"><code>ipairs (t)</code></a></h3>
7006 If <code>t</code> has a metamethod <code>__ipairs</code>,
7007 calls it with <code>t</code> as argument and returns the first three
7013 returns three values: an iterator function, the table <code>t</code>, and 0,
7019 will iterate over the pairs (<code>1,t[1]</code>), (<code>2,t[2]</code>), ...,
7026 <hr><h3><a name="pdf-load"><code>load (ld [, source [, mode [, env]]])</code></a></h3>
7034 If <code>ld</code> is a string, the chunk is this string.
7035 If <code>ld</code> is a function,
7036 <code>load</code> calls it repeatedly to get the chunk pieces.
7037 Each call to <code>ld</code> must return a string that concatenates
7050 the first upvalue is set to the value of <code>env</code>,
7055 the <code>_ENV</code> variable (see <a href="#2.2">&sect;2.2</a>).
7056 …binary chunk created from a function (see <a href="#pdf-string.dump"><code>string.dump</code></a>),
7061 <code>source</code> is used as the source of the chunk for error messages
7064 it defaults to <code>ld</code>, if <code>ld</code> is a string,
7065 or to "<code>=(load)</code>" otherwise.
7069 The string <code>mode</code> controls whether the chunk can be text or binary
7071 It may be the string "<code>b</code>" (only binary chunks),
7072 "<code>t</code>" (only text chunks),
7073 or "<code>bt</code>" (both binary and text).
7074 The default is "<code>bt</code>".
7080 <hr><h3><a name="pdf-loadfile"><code>loadfile ([filename [, mode [, env]]])</code></a></h3>
7084 Similar to <a href="#pdf-load"><code>load</code></a>,
7085 but gets the chunk from file <code>filename</code>
7093 <hr><h3><a name="pdf-next"><code>next (table [, index])</code></a></h3>
7100 <code>next</code> returns the next index of the table
7103 <code>next</code> returns an initial index
7107 <code>next</code> returns <b>nil</b>.
7110 you can use <code>next(t)</code> to check whether a table is empty.
7121 The behavior of <code>next</code> is undefined if,
7131 <hr><h3><a name="pdf-pairs"><code>pairs (t)</code></a></h3>
7135 If <code>t</code> has a metamethod <code>__pairs</code>,
7136 calls it with <code>t</code> as argument and returns the first three
7142 returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</co…
7148 will iterate over all key&ndash;value pairs of table <code>t</code>.
7152 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
7159 <hr><h3><a name="pdf-pcall"><code>pcall (f [, arg1, &middot;&middot;&middot;])</code></a></h3>
7163 Calls function <code>f</code> with
7165 This means that any error inside&nbsp;<code>f</code> is not propagated;
7166 instead, <code>pcall</code> catches the error
7167 and returns a status code.
7168 Its first result is the status code (a boolean),
7170 In such case, <code>pcall</code> also returns all results from the call,
7172 In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.
7178 <hr><h3><a name="pdf-print"><code>print (&middot;&middot;&middot;)</code></a></h3>
7180 and prints their values to <code>stdout</code>,
7181 using the <a href="#pdf-tostring"><code>tostring</code></a> function to convert each argument to a …
7182 <code>print</code> is not intended for formatted output,
7186 use <a href="#pdf-string.format"><code>string.format</code></a> and <a href="#pdf-io.write"><code>i…
7192 <hr><h3><a name="pdf-rawequal"><code>rawequal (v1, v2)</code></a></h3>
7193 Checks whether <code>v1</code> is equal to <code>v2</code>,
7201 <hr><h3><a name="pdf-rawget"><code>rawget (table, index)</code></a></h3>
7202 Gets the real value of <code>table[index]</code>,
7204 <code>table</code> must be a table;
7205 <code>index</code> may be any value.
7211 <hr><h3><a name="pdf-rawlen"><code>rawlen (v)</code></a></h3>
7212 Returns the length of the object <code>v</code>,
7221 <hr><h3><a name="pdf-rawset"><code>rawset (table, index, value)</code></a></h3>
7222 Sets the real value of <code>table[index]</code> to <code>value</code>,
7224 <code>table</code> must be a table,
7225 <code>index</code> any value different from <b>nil</b> and NaN,
7226 and <code>value</code> any Lua value.
7230 This function returns <code>table</code>.
7236 <hr><h3><a name="pdf-select"><code>select (index, &middot;&middot;&middot;)</code></a></h3>
7240 If <code>index</code> is a number,
7241 returns all arguments after argument number <code>index</code>;
7243 Otherwise, <code>index</code> must be the string <code>"#"</code>,
7244 and <code>select</code> returns the total number of extra arguments it received.
7250 <hr><h3><a name="pdf-setmetatable"><code>setmetatable (table, metatable)</code></a></h3>
7256 If <code>metatable</code> is <b>nil</b>,
7258 If the original metatable has a <code>"__metatable"</code> field,
7263 This function returns <code>table</code>.
7269 <hr><h3><a name="pdf-tonumber"><code>tonumber (e [, base])</code></a></h3>
7273 When called with no <code>base</code>,
7274 <code>tonumber</code> tries to convert its argument to a number.
7277 then <code>tonumber</code> returns this number;
7282 When called with <code>base</code>,
7283 then <code>e</code> should be a string to be interpreted as
7286 In bases above&nbsp;10, the letter '<code>A</code>' (in either upper or lower case)
7287 represents&nbsp;10, '<code>B</code>' represents&nbsp;11, and so forth,
7288 with '<code>Z</code>' representing 35.
7289 If the string <code>e</code> is not a valid numeral in the given base,
7296 <hr><h3><a name="pdf-tostring"><code>tostring (v)</code></a></h3>
7300 use <a href="#pdf-string.format"><code>string.format</code></a>.)
7304 If the metatable of <code>v</code> has a <code>"__tostring"</code> field,
7305 then <code>tostring</code> calls the corresponding value
7306 with <code>v</code> as argument,
7313 <hr><h3><a name="pdf-type"><code>type (v)</code></a></h3>
7316 "<code>nil</code>" (a string, not the value <b>nil</b>),
7317 "<code>number</code>",
7318 "<code>string</code>",
7319 "<code>boolean</code>",
7320 "<code>table</code>",
7321 "<code>function</code>",
7322 "<code>thread</code>",
7323 and "<code>userdata</code>".
7329 <hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
7332 The current contents of this variable is "<code>Lua 5.2</code>".
7338 <hr><h3><a name="pdf-xpcall"><code>xpcall (f, msgh [, arg1, &middot;&middot;&middot;])</code></a></…
7342 This function is similar to <a href="#pdf-pcall"><code>pcall</code></a>,
7343 except that it sets a new message handler <code>msgh</code>.
7355 the basic library and come inside the table <a name="pdf-coroutine"><code>coroutine</code></a>.
7360 <hr><h3><a name="pdf-coroutine.create"><code>coroutine.create (f)</code></a></h3>
7364 Creates a new coroutine, with body <code>f</code>.
7365 <code>f</code> must be a Lua function.
7367 an object with type <code>"thread"</code>.
7373 <hr><h3><a name="pdf-coroutine.resume"><code>coroutine.resume (co [, val1, &middot;&middot;&middot;…
7377 Starts or continues the execution of coroutine <code>co</code>.
7380 The values <code>val1</code>, ... are passed
7383 <code>resume</code> restarts it;
7384 the values <code>val1</code>, ... are passed
7390 <code>resume</code> returns <b>true</b> plus any values passed to <code>yield</code>
7394 <code>resume</code> returns <b>false</b> plus the error message.
7400 <hr><h3><a name="pdf-coroutine.running"><code>coroutine.running ()</code></a></h3>
7411 <hr><h3><a name="pdf-coroutine.status"><code>coroutine.status (co)</code></a></h3>
7415 Returns the status of coroutine <code>co</code>, as a string:
7416 <code>"running"</code>,
7417 if the coroutine is running (that is, it called <code>status</code>);
7418 <code>"suspended"</code>, if the coroutine is suspended in a call to <code>yield</code>,
7420 <code>"normal"</code> if the coroutine is active but not running
7422 and <code>"dead"</code> if the coroutine has finished its body function,
7429 <hr><h3><a name="pdf-coroutine.wrap"><code>coroutine.wrap (f)</code></a></h3>
7433 Creates a new coroutine, with body <code>f</code>.
7434 <code>f</code> must be a Lua function.
7437 extra arguments to <code>resume</code>.
7438 Returns the same values returned by <code>resume</code>,
7446 <hr><h3><a name="pdf-coroutine.yield"><code>coroutine.yield (&middot;&middot;&middot;)</code></a></…
7451 Any arguments to <code>yield</code> are passed as extra results to <code>resume</code>.
7465 <a href="#pdf-require"><code>require</code></a>.
7466 Everything else is exported in a table <a name="pdf-package"><code>package</code></a>.
7470 <hr><h3><a name="pdf-require"><code>require (modname)</code></a></h3>
7475 The function starts by looking into the <a href="#pdf-package.loaded"><code>package.loaded</code></…
7476 to determine whether <code>modname</code> is already loaded.
7477 If it is, then <code>require</code> returns the value stored
7478 at <code>package.loaded[modname]</code>.
7484 <code>require</code> is guided by the <a href="#pdf-package.searchers"><code>package.searchers</cod…
7486 we can change how <code>require</code> looks for a module.
7488 for <a href="#pdf-package.searchers"><code>package.searchers</code></a>.
7492 First <code>require</code> queries <code>package.preload[modname]</code>.
7495 Otherwise <code>require</code> searches for a Lua loader using the
7496 path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
7498 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
7500 …m>all-in-one</em> loader (see <a href="#pdf-package.searchers"><code>package.searchers</code></a>).
7505 <code>require</code> calls the loader with two arguments:
7506 <code>modname</code> and an extra value dependent on how it got the loader.
7510 <code>require</code> assigns the returned value to <code>package.loaded[modname]</code>.
7512 has not assigned any value to <code>package.loaded[modname]</code>,
7513 then <code>require</code> assigns <b>true</b> to this entry.
7514 In any case, <code>require</code> returns the
7515 final value of <code>package.loaded[modname]</code>.
7521 then <code>require</code> raises an error.
7527 <hr><h3><a name="pdf-package.config"><code>package.config</code></a></h3>
7537 Default is '<code>\</code>' for Windows and '<code>/</code>' for all other systems.</li>
7540 Default is '<code>;</code>'.</li>
7544 Default is '<code>?</code>'.</li>
7548 Default is '<code>!</code>'.</li>
7551 when building the <code>luaopen_</code> function name.
7552 Default is '<code>-</code>'.</li>
7559 <hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
7563 The path used by <a href="#pdf-require"><code>require</code></a> to search for a C&nbsp;loader.
7567 Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the …
7568 it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
7569 using the environment variable <a name="pdf-LUA_CPATH_5_2"><code>LUA_CPATH_5_2</code></a>
7570 or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
7571 or a default path defined in <code>luaconf.h</code>.
7577 <hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
7581 A table used by <a href="#pdf-require"><code>require</code></a> to control which
7583 When you require a module <code>modname</code> and
7584 <code>package.loaded[modname]</code> is not false,
7585 <a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
7591 table used by <a href="#pdf-require"><code>require</code></a>.
7597 <hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
7601 Dynamically links the host program with the C&nbsp;library <code>libname</code>.
7605 If <code>funcname</code> is "<code>*</code>",
7610 it looks for a function <code>funcname</code> inside the library
7612 So, <code>funcname</code> must follow the <a href="#lua_CFunction"><code>lua_CFunction</code></a> p…
7613 (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
7619 Unlike <a href="#pdf-require"><code>require</code></a>,
7622 <code>libname</code> must be the complete file name of the C&nbsp;library,
7624 <code>funcname</code> must be the exact name exported by the C&nbsp;library
7632 plus other Unix systems that support the <code>dlfcn</code> standard).
7638 <hr><h3><a name="pdf-package.path"><code>package.path</code></a></h3>
7642 The path used by <a href="#pdf-require"><code>require</code></a> to search for a Lua loader.
7647 the value of the environment variable <a name="pdf-LUA_PATH_5_2"><code>LUA_PATH_5_2</code></a> or
7648 the environment variable <a name="pdf-LUA_PATH"><code>LUA_PATH</code></a> or
7649 with a default path defined in <code>luaconf.h</code>,
7651 Any "<code>;;</code>" in the value of the environment variable
7658 <hr><h3><a name="pdf-package.preload"><code>package.preload</code></a></h3>
7663 (see <a href="#pdf-require"><code>require</code></a>).
7669 table used by <a href="#pdf-require"><code>require</code></a>.
7675 <hr><h3><a name="pdf-package.searchers"><code>package.searchers</code></a></h3>
7679 A table used by <a href="#pdf-require"><code>require</code></a> to control how to load modules.
7685 <a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
7686 with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
7700 <a href="#pdf-package.preload"><code>package.preload</code></a> table.
7705 using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
7706 …one as described in function <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
7711 using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
7713 …one as described in function <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
7720 the searcher for module <code>foo</code>
7721 will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>,
7722 and <code>/usr/local/foo/init.so</code>, in that order.
7728 The name of this C&nbsp;function is the string "<code>luaopen_</code>"
7733 For instance, if the module name is <code>a.v1-b.c</code>,
7734 the function name will be <code>luaopen_b_c</code>.
7741 For instance, when requiring <code>a.b.c</code>,
7742 it will search for a C&nbsp;library for <code>a</code>.
7745 in our example, that would be <code>luaopen_a_b_c</code>.
7754 as returned by <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
7761 <hr><h3><a name="pdf-package.searchpath"><code>package.searchpath (name, path [, sep [, rep]])</cod…
7765 Searches for the given <code>name</code> in the given <code>path</code>.
7773 in the template with a copy of <code>name</code>
7774 wherein all occurrences of <code>sep</code>
7776 were replaced by <code>rep</code>
7787 the search for the name <code>foo.a</code>
7789 <code>./foo/a.lua</code>, <code>./foo/a.lc</code>, and
7790 <code>/usr/local/foo/a/init.lua</code>, in that order.
7819 <a name="pdf-string"><code>string</code></a>.
7821 where the <code>__index</code> field points to the <code>string</code> table.
7823 For instance, <code>string.byte(s,i)</code>
7824 can be written as <code>s:byte(i)</code>.
7832 <hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
7833 Returns the internal numerical codes of the characters <code>s[i]</code>,
7834 <code>s[i+1]</code>, ..., <code>s[j]</code>.
7835 The default value for <code>i</code> is&nbsp;1;
7836 the default value for <code>j</code> is&nbsp;<code>i</code>.
7838 following the same rules of function <a href="#pdf-string.sub"><code>string.sub</code></a>.
7848 <hr><h3><a name="pdf-string.char"><code>string.char (&middot;&middot;&middot;)</code></a></h3>
7851 in which each character has the internal numerical code equal
7862 <hr><h3><a name="pdf-string.dump"><code>string.dump (function)</code></a></h3>
7867 so that a later <a href="#pdf-load"><code>load</code></a> on this string returns
7874 <hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
7879 <code>pattern</code> in the string <code>s</code>.
7880 If it finds a match, then <code>find</code> returns the indices of&nbsp;<code>s</code>
7883 A third, optional numerical argument <code>init</code> specifies
7886 A value of <b>true</b> as a fourth, optional argument <code>plain</code>
7889 with no characters in <code>pattern</code> being considered magic.
7890 Note that if <code>plain</code> is given, then <code>init</code> must be given as well.
7903 <hr><h3><a name="pdf-string.format"><code>string.format (formatstring, &middot;&middot;&middot;)</c…
7909 The format string follows the same rules as the ANSI&nbsp;C function <code>sprintf</code>.
7911 <code>*</code>, <code>h</code>, <code>L</code>, <code>l</code>, <code>n</code>,
7912 and <code>p</code> are not supported
7913 and that there is an extra option, <code>q</code>.
7914 The <code>q</code> option formats a string between double quotes,
7931 <code>A</code> and <code>a</code> (when available),
7932 <code>E</code>, <code>e</code>, <code>f</code>,
7933 <code>G</code>, and <code>g</code> all expect a number as argument.
7934 Options <code>c</code>, <code>d</code>,
7935 <code>i</code>, <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code>
7939 For options <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code>,
7941 Option <code>q</code> expects a string;
7942 option <code>s</code> expects a string without embedded zeros.
7943 If the argument to option <code>s</code> is not a string,
7944 it is converted to one following the same rules of <a href="#pdf-tostring"><code>tostring</code></a…
7950 <hr><h3><a name="pdf-string.gmatch"><code>string.gmatch (s, pattern)</code></a></h3>
7953 returns the next captures from <code>pattern</code> over the string <code>s</code>.
7954 If <code>pattern</code> specifies no captures,
7960 will iterate over all the words from string <code>s</code>,
7969 The next example collects all pairs <code>key=value</code> from the
7981 For this function, a caret '<code>^</code>' at the start of a pattern does not
7988 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
7989 Returns a copy of <code>s</code>
7990 in which all (or the first <code>n</code>, if given)
7991 occurrences of the <code>pattern</code> have been
7992 replaced by a replacement string specified by <code>repl</code>,
7994 <code>gsub</code> also returns, as its second value,
7996 The name <code>gsub</code> comes from <em>Global SUBstitution</em>.
8000 If <code>repl</code> is a string, then its value is used for replacement.
8001 The character&nbsp;<code>%</code> works as an escape character:
8002 any sequence in <code>repl</code> of the form <code>%<em>d</em></code>,
8005 The sequence <code>%0</code> stands for the whole match.
8006 The sequence <code>%%</code> stands for a single&nbsp;<code>%</code>.
8010 If <code>repl</code> is a table, then the table is queried for every match,
8015 If <code>repl</code> is a function, then this function is called every time a
8064 <hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
8066 The empty string <code>""</code> has length 0.
8068 so <code>"a\000bc\000"</code> has length 5.
8074 <hr><h3><a name="pdf-string.lower"><code>string.lower (s)</code></a></h3>
8084 <hr><h3><a name="pdf-string.match"><code>string.match (s, pattern [, init])</code></a></h3>
8086 <code>pattern</code> in the string <code>s</code>.
8087 If it finds one, then <code>match</code> returns
8090 If <code>pattern</code> specifies no captures,
8092 A third, optional numerical argument <code>init</code> specifies
8100 <hr><h3><a name="pdf-string.rep"><code>string.rep (s, n [, sep])</code></a></h3>
8101 Returns a string that is the concatenation of <code>n</code> copies of
8102 the string <code>s</code> separated by the string <code>sep</code>.
8103 The default value for <code>sep</code> is the empty string
8110 <hr><h3><a name="pdf-string.reverse"><code>string.reverse (s)</code></a></h3>
8111 Returns a string that is the string <code>s</code> reversed.
8117 <hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
8118 Returns the substring of <code>s</code> that
8119 starts at <code>i</code> and continues until <code>j</code>;
8120 <code>i</code> and <code>j</code> can be negative.
8121 If <code>j</code> is absent, then it is assumed to be equal to -1
8124 the call <code>string.sub(s,1,j)</code> returns a prefix of <code>s</code>
8125 with length <code>j</code>,
8126 and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>
8127 with length <code>i</code>.
8132 <code>i</code> is less than 1,
8134 If <code>j</code> is greater than the string length,
8137 <code>i</code> is greater than <code>j</code>,
8144 <hr><h3><a name="pdf-string.upper"><code>string.upper (s)</code></a></h3>
8163 <code>^$()%.[]*+-?</code>)
8167 <li><b><code>.</code>: </b> (a dot) represents all characters.</li>
8169 <li><b><code>%a</code>: </b> represents all letters.</li>
8171 <li><b><code>%c</code>: </b> represents all control characters.</li>
8173 <li><b><code>%d</code>: </b> represents all digits.</li>
8175 <li><b><code>%g</code>: </b> represents all printable characters except space.</li>
8177 <li><b><code>%l</code>: </b> represents all lowercase letters.</li>
8179 <li><b><code>%p</code>: </b> represents all punctuation characters.</li>
8181 <li><b><code>%s</code>: </b> represents all space characters.</li>
8183 <li><b><code>%u</code>: </b> represents all uppercase letters.</li>
8185 <li><b><code>%w</code>: </b> represents all alphanumeric characters.</li>
8187 <li><b><code>%x</code>: </b> represents all hexadecimal digits.</li>
8189 <li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character)
8193 can be preceded by a '<code>%</code>'
8197 <li><b><code>[<em>set</em>]</code>: </b>
8202 in ascending order, with a '<code>-</code>',
8203 All classes <code>%</code><em>x</em> described above can also be used as
8206 For example, <code>[%w_]</code> (or <code>[_%w]</code>)
8208 <code>[0-7]</code> represents the octal digits,
8209 and <code>[0-7%l%-]</code> represents the octal digits plus
8210 the lowercase letters plus the '<code>-</code>' character.
8215 Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code>
8219 <li><b><code>[^<em>set</em>]</code>: </b>
8225 For all classes represented by single letters (<code>%a</code>, <code>%c</code>, etc.),
8227 For instance, <code>%S</code> represents all non-space characters.
8233 In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.
8250 a single character class followed by '<code>*</code>',
8256 a single character class followed by '<code>+</code>',
8262 a single character class followed by '<code>-</code>',
8264 Unlike '<code>*</code>',
8269 a single character class followed by '<code>?</code>',
8274 <code>%<em>n</em></code>, for <em>n</em> between 1 and 9;
8280 <code>%b<em>xy</em></code>, where <em>x</em> and <em>y</em> are two distinct characters;
8286 For instance, the item <code>%b()</code> matches expressions with
8291 <code>%f[<em>set</em>]</code>, a <em>frontier pattern</em>;
8297 they were the character '<code>\0</code>'.
8307 A caret '<code>^</code>' at the beginning of a pattern anchors the match at the
8309 A '<code>$</code>' at the end of a pattern anchors the match at the
8312 '<code>^</code>' and '<code>$</code>' have no special meaning and represent themselves.
8324 For instance, in the pattern <code>"(a*(.)%w(%s*))"</code>,
8325 the part of the string matching <code>"a*(.)%w(%s*)"</code> is
8327 the character matching "<code>.</code>" is captured with number&nbsp;2,
8328 and the part matching "<code>%s*</code>" has number&nbsp;3.
8332 As a special case, the empty capture <code>()</code> captures
8334 For instance, if we apply the pattern <code>"()aa()"</code> on the
8335 string <code>"flaaap"</code>, there will be two captures: 3&nbsp;and&nbsp;5.
8351 It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.
8357 or have a <code>__len</code> metamethod (see <a href="#3.4.6">&sect;3.4.6</a>).
8368 <hr><h3><a name="pdf-table.concat"><code>table.concat (list [, sep [, i [, j]]])</code></a></h3>
8373 returns the string <code>list[i]..sep..list[i+1] &middot;&middot;&middot; sep..list[j]</code>.
8374 The default value for <code>sep</code> is the empty string,
8375 the default for <code>i</code> is 1,
8376 and the default for <code>j</code> is <code>#list</code>.
8377 If <code>i</code> is greater than <code>j</code>, returns the empty string.
8383 <hr><h3><a name="pdf-table.insert"><code>table.insert (list, [pos,] value)</code></a></h3>
8387 Inserts element <code>value</code> at position <code>pos</code> in <code>list</code>,
8389 <code>list[pos], list[pos+1], &middot;&middot;&middot;, list[#list]</code>.
8390 The default value for <code>pos</code> is <code>#list+1</code>,
8391 so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
8392 of list <code>t</code>.
8398 <hr><h3><a name="pdf-table.pack"><code>table.pack (&middot;&middot;&middot;)</code></a></h3>
8403 and with a field "<code>n</code>" with the total number of parameters.
8410 <hr><h3><a name="pdf-table.remove"><code>table.remove (list [, pos])</code></a></h3>
8414 Removes from <code>list</code> the element at position <code>pos</code>,
8416 When <code>pos</code> is an integer between 1 and <code>#list</code>,
8418 <code>list[pos+1], list[pos+2], &middot;&middot;&middot;, list[#list]</code>
8419 and erases element <code>list[#list]</code>;
8420 The index <code>pos</code> can also be 0 when <code>#list</code> is 0,
8421 or <code>#list + 1</code>;
8422 in those cases, the function erases the element <code>list[pos]</code>.
8426 The default value for <code>pos</code> is <code>#list</code>,
8427 so that a call <code>table.remove(t)</code> removes the last element
8428 of list <code>t</code>.
8434 <hr><h3><a name="pdf-table.sort"><code>table.sort (list [, comp])</code></a></h3>
8439 from <code>list[1]</code> to <code>list[#list]</code>.
8440 If <code>comp</code> is given,
8444 (so that <code>not comp(list[i+1],list[i])</code> will be true after the sort).
8445 If <code>comp</code> is not given,
8446 then the standard Lua operator <code>&lt;</code> is used instead.
8458 <hr><h3><a name="pdf-table.unpack"><code>table.unpack (list [, i [, j]])</code></a></h3>
8468 By default, <code>i</code> is&nbsp;1 and <code>j</code> is <code>#list</code>.
8480 It provides all its functions inside the table <a name="pdf-math"><code>math</code></a>.
8484 <hr><h3><a name="pdf-math.abs"><code>math.abs (x)</code></a></h3>
8488 Returns the absolute value of <code>x</code>.
8494 <hr><h3><a name="pdf-math.acos"><code>math.acos (x)</code></a></h3>
8498 Returns the arc cosine of <code>x</code> (in radians).
8504 <hr><h3><a name="pdf-math.asin"><code>math.asin (x)</code></a></h3>
8508 Returns the arc sine of <code>x</code> (in radians).
8514 <hr><h3><a name="pdf-math.atan"><code>math.atan (x)</code></a></h3>
8518 Returns the arc tangent of <code>x</code> (in radians).
8524 <hr><h3><a name="pdf-math.atan2"><code>math.atan2 (y, x)</code></a></h3>
8528 Returns the arc tangent of <code>y/x</code> (in radians),
8531 (It also handles correctly the case of <code>x</code> being zero.)
8537 <hr><h3><a name="pdf-math.ceil"><code>math.ceil (x)</code></a></h3>
8541 Returns the smallest integer larger than or equal to <code>x</code>.
8547 <hr><h3><a name="pdf-math.cos"><code>math.cos (x)</code></a></h3>
8551 Returns the cosine of <code>x</code> (assumed to be in radians).
8557 <hr><h3><a name="pdf-math.cosh"><code>math.cosh (x)</code></a></h3>
8561 Returns the hyperbolic cosine of <code>x</code>.
8567 <hr><h3><a name="pdf-math.deg"><code>math.deg (x)</code></a></h3>
8571 Returns the angle <code>x</code> (given in radians) in degrees.
8577 <hr><h3><a name="pdf-math.exp"><code>math.exp (x)</code></a></h3>
8587 <hr><h3><a name="pdf-math.floor"><code>math.floor (x)</code></a></h3>
8591 Returns the largest integer smaller than or equal to <code>x</code>.
8597 <hr><h3><a name="pdf-math.fmod"><code>math.fmod (x, y)</code></a></h3>
8601 Returns the remainder of the division of <code>x</code> by <code>y</code>
8608 <hr><h3><a name="pdf-math.frexp"><code>math.frexp (x)</code></a></h3>
8612 Returns <code>m</code> and <code>e</code> such that <em>x = m2<sup>e</sup></em>,
8613 <code>e</code> is an integer and the absolute value of <code>m</code> is
8615 (or zero when <code>x</code> is zero).
8621 <hr><h3><a name="pdf-math.huge"><code>math.huge</code></a></h3>
8625 The value <code>HUGE_VAL</code>,
8632 <hr><h3><a name="pdf-math.ldexp"><code>math.ldexp (m, e)</code></a></h3>
8636 Returns <em>m2<sup>e</sup></em> (<code>e</code> should be an integer).
8642 <hr><h3><a name="pdf-math.log"><code>math.log (x [, base])</code></a></h3>
8646 Returns the logarithm of <code>x</code> in the given base.
8647 The default for <code>base</code> is <em>e</em>
8648 (so that the function returns the natural logarithm of <code>x</code>).
8654 <hr><h3><a name="pdf-math.max"><code>math.max (x, &middot;&middot;&middot;)</code></a></h3>
8664 <hr><h3><a name="pdf-math.min"><code>math.min (x, &middot;&middot;&middot;)</code></a></h3>
8674 <hr><h3><a name="pdf-math.modf"><code>math.modf (x)</code></a></h3>
8679 the integral part of <code>x</code> and the fractional part of <code>x</code>.
8685 <hr><h3><a name="pdf-math.pi"><code>math.pi</code></a></h3>
8695 <hr><h3><a name="pdf-math.pow"><code>math.pow (x, y)</code></a></h3>
8700 (You can also use the expression <code>x^y</code> to compute this value.)
8706 <hr><h3><a name="pdf-math.rad"><code>math.rad (x)</code></a></h3>
8710 Returns the angle <code>x</code> (given in degrees) in radians.
8716 <hr><h3><a name="pdf-math.random"><code>math.random ([m [, n]])</code></a></h3>
8721 pseudo-random generator function <code>rand</code> provided by Standard&nbsp;C.
8729 When called with an integer number <code>m</code>,
8730 <code>math.random</code> returns
8732 When called with two integer numbers <code>m</code> and <code>n</code>,
8733 <code>math.random</code> returns a uniform pseudo-random
8740 <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed (x)</code></a></h3>
8744 Sets <code>x</code> as the "seed"
8752 <hr><h3><a name="pdf-math.sin"><code>math.sin (x)</code></a></h3>
8756 Returns the sine of <code>x</code> (assumed to be in radians).
8762 <hr><h3><a name="pdf-math.sinh"><code>math.sinh (x)</code></a></h3>
8766 Returns the hyperbolic sine of <code>x</code>.
8772 <hr><h3><a name="pdf-math.sqrt"><code>math.sqrt (x)</code></a></h3>
8776 Returns the square root of <code>x</code>.
8777 (You can also use the expression <code>x^0.5</code> to compute this value.)
8783 <hr><h3><a name="pdf-math.tan"><code>math.tan (x)</code></a></h3>
8787 Returns the tangent of <code>x</code> (assumed to be in radians).
8793 <hr><h3><a name="pdf-math.tanh"><code>math.tanh (x)</code></a></h3>
8797 Returns the hyperbolic tangent of <code>x</code>.
8809 It provides all its functions inside the table <a name="pdf-bit32"><code>bit32</code></a>.
8821 Note that <code>bit32.bnot(0)</code> is <code>0xFFFFFFFF</code>,
8822 which is different from <code>-1</code>.
8826 <hr><h3><a name="pdf-bit32.arshift"><code>bit32.arshift (x, disp)</code></a></h3>
8830 Returns the number <code>x</code> shifted <code>disp</code> bits to the right.
8831 The number <code>disp</code> may be any representable integer.
8838 with copies of the higher bit of <code>x</code>;
8842 result in zero or <code>0xFFFFFFFF</code> (all original bits are shifted out).
8848 <hr><h3><a name="pdf-bit32.band"><code>bit32.band (&middot;&middot;&middot;)</code></a></h3>
8858 <hr><h3><a name="pdf-bit32.bnot"><code>bit32.bnot (x)</code></a></h3>
8862 Returns the bitwise negation of <code>x</code>.
8863 For any integer <code>x</code>,
8873 <hr><h3><a name="pdf-bit32.bor"><code>bit32.bor (&middot;&middot;&middot;)</code></a></h3>
8883 <hr><h3><a name="pdf-bit32.btest"><code>bit32.btest (&middot;&middot;&middot;)</code></a></h3>
8894 <hr><h3><a name="pdf-bit32.bxor"><code>bit32.bxor (&middot;&middot;&middot;)</code></a></h3>
8904 <hr><h3><a name="pdf-bit32.extract"><code>bit32.extract (n, field [, width])</code></a></h3>
8909 <code>field</code> to <code>field + width - 1</code> from <code>n</code>.
8915 The default for <code>width</code> is 1.
8921 <hr><h3><a name="pdf-bit32.replace"><code>bit32.replace (n, v, field [, width])</code></a></h3>
8925 Returns a copy of <code>n</code> with
8926 the bits <code>field</code> to <code>field + width - 1</code>
8927 replaced by the value <code>v</code>.
8928 …e <a href="#pdf-bit32.extract"><code>bit32.extract</code></a> for details about <code>field</code>…
8934 <hr><h3><a name="pdf-bit32.lrotate"><code>bit32.lrotate (x, disp)</code></a></h3>
8938 Returns the number <code>x</code> rotated <code>disp</code> bits to the left.
8939 The number <code>disp</code> may be any representable integer.
8956 <hr><h3><a name="pdf-bit32.lshift"><code>bit32.lshift (x, disp)</code></a></h3>
8960 Returns the number <code>x</code> shifted <code>disp</code> bits to the left.
8961 The number <code>disp</code> may be any representable integer.
8980 <hr><h3><a name="pdf-bit32.rrotate"><code>bit32.rrotate (x, disp)</code></a></h3>
8984 Returns the number <code>x</code> rotated <code>disp</code> bits to the right.
8985 The number <code>disp</code> may be any representable integer.
9002 <hr><h3><a name="pdf-bit32.rshift"><code>bit32.rshift (x, disp)</code></a></h3>
9006 Returns the number <code>x</code> shifted <code>disp</code> bits to the right.
9007 The number <code>disp</code> may be any representable integer.
9045 all operations are supplied by table <a name="pdf-io"><code>io</code></a>.
9047 the operation <a href="#pdf-io.open"><code>io.open</code></a> returns a file descriptor
9052 The table <code>io</code> also provides
9054 …f-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a>, and <a …
9062 a system-dependent error code as a third result)
9065 the computation of the error message and error code
9068 because they rely on the global C variable <code>errno</code>.
9072 <hr><h3><a name="pdf-io.close"><code>io.close ([file])</code></a></h3>
9076 Equivalent to <code>file:close()</code>.
9077 Without a <code>file</code>, closes the default output file.
9083 <hr><h3><a name="pdf-io.flush"><code>io.flush ()</code></a></h3>
9087 Equivalent to <code>io.output():flush()</code>.
9093 <hr><h3><a name="pdf-io.input"><code>io.input ([file])</code></a></h3>
9107 instead of returning an error code.
9113 <hr><h3><a name="pdf-io.lines"><code>io.lines ([filename &middot;&middot;&middot;])</code></a></h3>
9119 works like <code>file:lines(&middot;&middot;&middot;)</code> over the opened file.
9125 The call <code>io.lines()</code> (with no file name) is equivalent
9126 to <code>io.input():lines()</code>;
9133 instead of returning an error code.
9139 <hr><h3><a name="pdf-io.open"><code>io.open (filename [, mode])</code></a></h3>
9144 in the mode specified in the string <code>mode</code>.
9150 The <code>mode</code> string can be any of the following:
9153 <li><b>"<code>r</code>": </b> read mode (the default);</li>
9154 <li><b>"<code>w</code>": </b> write mode;</li>
9155 <li><b>"<code>a</code>": </b> append mode;</li>
9156 <li><b>"<code>r+</code>": </b> update mode, all previous data is preserved;</li>
9157 <li><b>"<code>w+</code>": </b> update mode, all previous data is erased;</li>
9158 <li><b>"<code>a+</code>": </b> append update mode, previous data is preserved,
9161 The <code>mode</code> string can also have a '<code>b</code>' at the end,
9168 <hr><h3><a name="pdf-io.output"><code>io.output ([file])</code></a></h3>
9172 Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output …
9178 <hr><h3><a name="pdf-io.popen"><code>io.popen (prog [, mode])</code></a></h3>
9187 Starts program <code>prog</code> in a separated process and returns
9189 (if <code>mode</code> is <code>"r"</code>, the default)
9191 (if <code>mode</code> is <code>"w"</code>).
9197 <hr><h3><a name="pdf-io.read"><code>io.read (&middot;&middot;&middot;)</code></a></h3>
9201 Equivalent to <code>io.input():read(&middot;&middot;&middot;)</code>.
9207 <hr><h3><a name="pdf-io.tmpfile"><code>io.tmpfile ()</code></a></h3>
9219 <hr><h3><a name="pdf-io.type"><code>io.type (obj)</code></a></h3>
9223 Checks whether <code>obj</code> is a valid file handle.
9224 Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,
9225 <code>"closed file"</code> if <code>obj</code> is a closed file handle,
9226 or <b>nil</b> if <code>obj</code> is not a file handle.
9232 <hr><h3><a name="pdf-io.write"><code>io.write (&middot;&middot;&middot;)</code></a></h3>
9236 Equivalent to <code>io.output():write(&middot;&middot;&middot;)</code>.
9242 <hr><h3><a name="pdf-file:close"><code>file:close ()</code></a></h3>
9246 Closes <code>file</code>.
9253 When closing a file handle created with <a href="#pdf-io.popen"><code>io.popen</code></a>,
9254 <a href="#pdf-file:close"><code>file:close</code></a> returns the same values
9255 returned by <a href="#pdf-os.execute"><code>os.execute</code></a>.
9261 <hr><h3><a name="pdf-file:flush"><code>file:flush ()</code></a></h3>
9265 Saves any written data to <code>file</code>.
9271 <hr><h3><a name="pdf-file:lines"><code>file:lines (&middot;&middot;&middot;)</code></a></h3>
9287 Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
9293 instead of returning an error code.
9299 <hr><h3><a name="pdf-file:read"><code>file:read (&middot;&middot;&middot;)</code></a></h3>
9303 Reads the file <code>file</code>,
9318 <li><b>"<code>*n</code>": </b>
9323 <li><b>"<code>*a</code>": </b>
9328 <li><b>"<code>*l</code>": </b>
9334 <li><b>"<code>*L</code>": </b>
9352 <hr><h3><a name="pdf-file:seek"><code>file:seek ([whence [, offset]])</code></a></h3>
9358 to the position given by <code>offset</code> plus a base
9359 specified by the string <code>whence</code>, as follows:
9362 <li><b>"<code>set</code>": </b> base is position 0 (beginning of the file);</li>
9363 <li><b>"<code>cur</code>": </b> base is current position;</li>
9364 <li><b>"<code>end</code>": </b> base is end of file;</li>
9366 In case of success, <code>seek</code> returns the final file position,
9368 If <code>seek</code> fails, it returns <b>nil</b>,
9373 The default value for <code>whence</code> is <code>"cur"</code>,
9374 and for <code>offset</code> is 0.
9375 Therefore, the call <code>file:seek()</code> returns the current
9377 the call <code>file:seek("set")</code> sets the position to the
9379 and the call <code>file:seek("end")</code> sets the position to the
9386 <hr><h3><a name="pdf-file:setvbuf"><code>file:setvbuf (mode [, size])</code></a></h3>
9395 <li><b>"<code>no</code>": </b>
9399 <li><b>"<code>full</code>": </b>
9402 you explicitly <code>flush</code> the file (see <a href="#pdf-io.flush"><code>io.flush</code></a>).
9405 <li><b>"<code>line</code>": </b>
9412 For the last two cases, <code>size</code>
9420 <hr><h3><a name="pdf-file:write"><code>file:write (&middot;&middot;&middot;)</code></a></h3>
9424 Writes the value of each of its arguments to <code>file</code>.
9429 In case of success, this function returns <code>file</code>.
9441 This library is implemented through table <a name="pdf-os"><code>os</code></a>.
9445 <hr><h3><a name="pdf-os.clock"><code>os.clock ()</code></a></h3>
9456 <hr><h3><a name="pdf-os.date"><code>os.date ([format [, time]])</code></a></h3>
9461 formatted according to the given string <code>format</code>.
9465 If the <code>time</code> argument is present,
9467 (see the <a href="#pdf-os.time"><code>os.time</code></a> function for a description of this value).
9468 Otherwise, <code>date</code> formats the current time.
9472 If <code>format</code> starts with '<code>!</code>',
9475 if <code>format</code> is the string "<code>*t</code>",
9476 then <code>date</code> returns a table with the following fields:
9477 <code>year</code> (four digits), <code>month</code> (1&ndash;12), <code>day</code> (1&ndash;31),
9478 <code>hour</code> (0&ndash;23), <code>min</code> (0&ndash;59), <code>sec</code> (0&ndash;61),
9479 <code>wday</code> (weekday, Sunday is&nbsp;1),
9480 <code>yday</code> (day of the year),
9481 and <code>isdst</code> (daylight saving flag, a boolean).
9487 If <code>format</code> is not "<code>*t</code>",
9488 then <code>date</code> returns the date as a string,
9489 formatted according to the same rules as the ANSI&nbsp;C function <code>strftime</code>.
9494 <code>date</code> returns a reasonable date and time representation that depends on
9496 (that is, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>).
9502 because of its reliance on C&nbsp;function <code>gmtime</code> and C&nbsp;function <code>localtime<…
9508 <hr><h3><a name="pdf-os.difftime"><code>os.difftime (t2, t1)</code></a></h3>
9512 Returns the number of seconds from time <code>t1</code> to time <code>t2</code>.
9514 this value is exactly <code>t2</code><em>-</em><code>t1</code>.
9520 <hr><h3><a name="pdf-os.execute"><code>os.execute ([command])</code></a></h3>
9524 This function is equivalent to the ANSI&nbsp;C function <code>system</code>.
9525 It passes <code>command</code> to be executed by an operating system shell.
9535 <li><b>"<code>exit</code>": </b>
9540 <li><b>"<code>signal</code>": </b>
9548 When called without a <code>command</code>,
9549 <code>os.execute</code> returns a boolean that is true if a shell is available.
9555 <hr><h3><a name="pdf-os.exit"><code>os.exit ([code [, close])</code></a></h3>
9559 Calls the ANSI&nbsp;C function <code>exit</code> to terminate the host program.
9560 If <code>code</code> is <b>true</b>,
9561 the returned status is <code>EXIT_SUCCESS</code>;
9562 if <code>code</code> is <b>false</b>,
9563 the returned status is <code>EXIT_FAILURE</code>;
9564 if <code>code</code> is a number,
9566 The default value for <code>code</code> is <b>true</b>.
9570 If the optional second argument <code>close</code> is true,
9577 <hr><h3><a name="pdf-os.getenv"><code>os.getenv (varname)</code></a></h3>
9581 Returns the value of the process environment variable <code>varname</code>,
9588 <hr><h3><a name="pdf-os.remove"><code>os.remove (filename)</code></a></h3>
9595 plus a string describing the error and the error code.
9601 <hr><h3><a name="pdf-os.rename"><code>os.rename (oldname, newname)</code></a></h3>
9605 Renames file or directory named <code>oldname</code> to <code>newname</code>.
9607 plus a string describing the error and the error code.
9613 <hr><h3><a name="pdf-os.setlocale"><code>os.setlocale (locale [, category])</code></a></h3>
9618 <code>locale</code> is a system-dependent string specifying a locale;
9619 <code>category</code> is an optional string describing which category to change:
9620 <code>"all"</code>, <code>"collate"</code>, <code>"ctype"</code>,
9621 <code>"monetary"</code>, <code>"numeric"</code>, or <code>"time"</code>;
9622 the default category is <code>"all"</code>.
9628 If <code>locale</code> is the empty string,
9630 If <code>locale</code> is the string "<code>C</code>",
9642 because of its reliance on C&nbsp;function <code>setlocale</code>.
9648 <hr><h3><a name="pdf-os.time"><code>os.time ([table])</code></a></h3>
9654 This table must have fields <code>year</code>, <code>month</code>, and <code>day</code>,
9656 <code>hour</code> (default is 12),
9657 <code>min</code> (default is 0),
9658 <code>sec</code> (default is 0),
9659 and <code>isdst</code> (default is <b>nil</b>).
9660 For a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function.
9669 and the number returned by <code>time</code> can be used only as an argument to
9670 <a href="#pdf-os.date"><code>os.date</code></a> and <a href="#pdf-os.difftime"><code>os.difftime</c…
9676 <hr><h3><a name="pdf-os.tmpname"><code>os.tmpname ()</code></a></h3>
9698 you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
9714 violate basic assumptions about Lua code
9717 that userdata metatables cannot be changed by Lua code;
9719 and therefore can compromise otherwise secure code.
9725 inside the <a name="pdf-debug"><code>debug</code></a> table.
9733 <hr><h3><a name="pdf-debug.debug"><code>debug.debug ()</code></a></h3>
9742 A line containing only the word <code>cont</code> finishes this function,
9747 Note that commands for <code>debug.debug</code> are not lexically nested
9754 <hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
9761 (as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).
9767 <hr><h3><a name="pdf-debug.getinfo"><code>debug.getinfo ([thread,] f [, what])</code></a></h3>
9773 or you can give a number as the value of <code>f</code>,
9774 which means the function running at level <code>f</code> of the call stack
9776 level&nbsp;0 is the current function (<code>getinfo</code> itself);
9777 level&nbsp;1 is the function that called <code>getinfo</code>
9780 If <code>f</code> is a number larger than the number of active functions,
9781 then <code>getinfo</code> returns <b>nil</b>.
9785 …d table can contain all the fields returned by <a href="#lua_getinfo"><code>lua_getinfo</code></a>,
9786 with the string <code>what</code> describing which fields to fill in.
9787 The default for <code>what</code> is to get all information available,
9790 the option '<code>f</code>'
9791 adds a field named <code>func</code> with the function itself.
9793 the option '<code>L</code>'
9794 adds a field named <code>activelines</code> with the table of
9799 For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
9802 and the expression <code>debug.getinfo(print)</code>
9804 about the <a href="#pdf-print"><code>print</code></a> function.
9810 <hr><h3><a name="pdf-debug.getlocal"><code>debug.getlocal ([thread,] f, local)</code></a></h3>
9815 with index <code>local</code> of the function at level <code>f</code> of the stack.
9827 (You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the leve…
9831 Variable names starting with '<code>(</code>' (open parenthesis)
9837 The parameter <code>f</code> may also be a function.
9838 In that case, <code>getlocal</code> returns only the name of function parameters.
9844 <hr><h3><a name="pdf-debug.getmetatable"><code>debug.getmetatable (value)</code></a></h3>
9848 Returns the metatable of the given <code>value</code>
9855 <hr><h3><a name="pdf-debug.getregistry"><code>debug.getregistry ()</code></a></h3>
9865 <hr><h3><a name="pdf-debug.getupvalue"><code>debug.getupvalue (f, up)</code></a></h3>
9870 with index <code>up</code> of the function <code>f</code>.
9877 <hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3>
9881 Returns the Lua value associated to <code>u</code>.
9882 If <code>u</code> is not a userdata,
9889 <hr><h3><a name="pdf-debug.sethook"><code>debug.sethook ([thread,] hook, mask [, count])</code></a>…
9894 The string <code>mask</code> and the number <code>count</code> describe
9900 <li><b>'<code>c</code>': </b> the hook is called every time Lua calls a function;</li>
9901 <li><b>'<code>r</code>': </b> the hook is called every time Lua returns from a function;</li>
9902 <li><b>'<code>l</code>': </b> the hook is called every time Lua enters a new line of code.</li>
9904 With a <code>count</code> different from zero,
9905 the hook is called after every <code>count</code> instructions.
9910 <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> turns off the hook.
9916 <code>"call"</code> (or <code>"tail call"</code>),
9917 <code>"return"</code>,
9918 <code>"line"</code>, and <code>"count"</code>.
9922 you can call <code>getinfo</code> with level&nbsp;2 to get more information about
9924 (level&nbsp;0 is the <code>getinfo</code> function,
9931 <hr><h3><a name="pdf-debug.setlocal"><code>debug.setlocal ([thread,] level, local, value)</code></a…
9935 This function assigns the value <code>value</code> to the local variable
9936 with index <code>local</code> of the function at level <code>level</code> of the stack.
9939 and raises an error when called with a <code>level</code> out of range.
9940 (You can call <code>getinfo</code> to check whether the level is valid.)
9945 See <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for more information about
9952 <hr><h3><a name="pdf-debug.setmetatable"><code>debug.setmetatable (value, table)</code></a></h3>
9956 Sets the metatable for the given <code>value</code> to the given <code>table</code>
9958 Returns <code>value</code>.
9964 <hr><h3><a name="pdf-debug.setupvalue"><code>debug.setupvalue (f, up, value)</code></a></h3>
9968 This function assigns the value <code>value</code> to the upvalue
9969 with index <code>up</code> of the function <code>f</code>.
9978 <hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3>
9982 Sets the given <code>value</code> as
9983 the Lua value associated to the given <code>udata</code>.
9984 <code>value</code> must be a table or <b>nil</b>;
9985 <code>udata</code> must be a full userdata.
9989 Returns <code>udata</code>.
9995 <hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code><…
9999 If <code>message</code> is present but is neither a string nor <b>nil</b>,
10000 this function returns <code>message</code> without further processing.
10003 An optional <code>message</code> string is appended
10005 An optional <code>level</code> number tells at which level
10007 (default is 1, the function calling <code>traceback</code>).
10013 <hr><h3><a name="pdf-debug.upvalueid"><code>debug.upvalueid (f, n)</code></a></h3>
10018 for the upvalue numbered <code>n</code>
10033 <hr><h3><a name="pdf-debug.upvaluejoin"><code>debug.upvaluejoin (f1, n1, f2, n2)</code></a></h3>
10037 Make the <code>n1</code>-th upvalue of the Lua closure <code>f1</code>
10038 refer to the <code>n2</code>-th upvalue of the Lua closure <code>f2</code>.
10053 called simply <code>lua</code>,
10065 <li><b><code>-e <em>stat</em></code>: </b> executes string <em>stat</em>;</li>
10066 <li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em>;</li>
10067 <li><b><code>-i</code>: </b> enters interactive mode after running <em>script</em>;</li>
10068 <li><b><code>-v</code>: </b> prints version information;</li>
10069 <li><b><code>-E</code>: </b> ignores environment variables;</li>
10070 <li><b><code>--</code>: </b> stops handling options;</li>
10071 <li><b><code>-</code>: </b> executes <code>stdin</code> as a file and stops handling options.</li>
10073 After handling its options, <code>lua</code> runs the given <em>script</em>,
10076 <code>lua</code> behaves as <code>lua -v -i</code>
10077 when the standard input (<code>stdin</code>) is a terminal,
10078 and as <code>lua -</code> otherwise.
10082 When called without option <code>-E</code>,
10083 …rpreter checks for an environment variable <a name="pdf-LUA_INIT_5_2"><code>LUA_INIT_5_2</code></a>
10084 (or <a name="pdf-LUA_INIT"><code>LUA_INIT</code></a> if it is not defined)
10086 If the variable content has the format <code>@<em>filename</em></code>,
10087 then <code>lua</code> executes the file.
10088 Otherwise, <code>lua</code> executes the string itself.
10092 When called with option <code>-E</code>,
10093 besides ignoring <code>LUA_INIT</code>,
10095 the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>,
10097 <a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.cpath"><code>pa…
10098 with the default paths defined in <code>luaconf.h</code>.
10102 All options are handled in order, except <code>-i</code> and <code>-E</code>.
10108 will first set <code>a</code> to 1, then print the value of <code>a</code>,
10109 and finally run the file <code>script.lua</code> with no arguments.
10110 (Here <code>$</code> is the shell prompt. Your prompt may be different.)
10115 <code>lua</code> collects all arguments in the command line
10116 in a global table called <code>arg</code>.
10128 the interpreter first runs the file <code>a.lua</code>,
10136 and finally runs the file <code>b.lua</code>.
10137 The script is called with <code>arg[1]</code>, <code>arg[2]</code>, ...
10139 it can also access these arguments with the vararg expression '<code>...</code>'.
10154 Otherwise, if the error object has a metamethod <code>__tostring</code>,
10163 (see <a href="#lua_close"><code>lua_close</code></a>).
10165 calling <a href="#pdf-os.exit"><code>os.exit</code></a> to terminate.
10172 the first line of a chunk if it starts with <code>#</code>.
10174 by using <code>chmod +x</code> and the&nbsp;<code>#!</code> form,
10182 If <code>lua</code> is in your <code>PATH</code>,
10198 appropriate options (see file <code>luaconf.h</code>).
10214 use the variable <code>_ENV</code> or the function <a href="#pdf-load"><code>load</code></a>.
10221 (You may use <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a> to open a C library
10229 <a href="#lua_getuservalue"><code>lua_getuservalue</code></a> and <a href="#lua_setuservalue"><code
10268 Function <code>module</code> is deprecated.
10269 It is easy to set up a module with regular Lua code.
10274 Functions <code>setfenv</code> and <code>getfenv</code> were removed,
10279 Function <code>math.log10</code> is deprecated.
10280 Use <a href="#pdf-math.log"><code>math.log</code></a> with 10 as its second argument, instead.
10284 Function <code>loadstring</code> is deprecated.
10285 Use <code>load</code> instead; it now accepts string arguments
10286 and are exactly equivalent to <code>loadstring</code>.
10290 Function <code>table.maxn</code> is deprecated.
10295 Function <code>os.execute</code> now returns <b>true</b> when command
10301 Function <code>unpack</code> was moved into the table library
10302 and therefore must be called as <a href="#pdf-table.unpack"><code>table.unpack</code></a>.
10306 Character class <code>%z</code> in patterns is deprecated,
10307 as now patterns may contain '<code>\0</code>' as a regular character.
10311 The table <code>package.loaders</code> was renamed <code>package.searchers</code>.
10316 So, all functions that load code
10317 (<a href="#pdf-load"><code>load</code></a> and <a href="#pdf-loadfile"><code>loadfile</code></a>)
10322 use the <code>mode</code> argument of those functions
10340 Pseudoindex <code>LUA_GLOBALSINDEX</code> was removed.
10346 Pseudoindex <code>LUA_ENVIRONINDEX</code>
10347 and functions <code>lua_getfenv</code>/<code>lua_setfenv</code>
10353 Function <code>luaL_register</code> is deprecated.
10354 Use <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a> so that your module does not create glo…
10359 The <code>osize</code> argument to the allocation function
10361 that is, when <code>ptr</code> is <code>NULL</code>
10362 (see <a href="#lua_Alloc"><code>lua_Alloc</code></a>).
10363 Use only the test <code>ptr == NULL</code> to check whether
10368 Finalizers (<code>__gc</code> metamethods) for userdata are called in the
10373 if the metatable does not have a <code>__gc</code> field when set,
10379 <code>luaL_typerror</code> was removed.
10384 Function <code>lua_cpcall</code> is deprecated.
10385 You can simply push the function with <a href="#lua_pushcfunction"><code>lua_pushcfunction</code></…
10386 and call it with <a href="#lua_pcall"><code>lua_pcall</code></a>.
10390 Functions <code>lua_equal</code> and <code>lua_lessthan</code> are deprecated.
10391 Use the new <a href="#lua_compare"><code>lua_compare</code></a> with appropriate options instead.
10395 Function <code>lua_objlen</code> was renamed <a href="#lua_rawlen"><code>lua_rawlen</code></a>.
10399 Function <a href="#lua_load"><code>lua_load</code></a> has an extra parameter, <code>mode</code>.
10400 Pass <code>NULL</code> to simulate the old behavior.
10404 Function <a href="#lua_resume"><code>lua_resume</code></a> has an extra parameter, <code>from</code
10405 Pass <code>NULL</code> or the thread doing the call.