• Home
  • Raw
  • Download

Lines Matching full:code

67 The Lua distribution includes a host program called <code>lua</code>,
80 (Frequently, this host is the stand-alone <code>lua</code> program.)
81 The host program can invoke functions to execute a piece of Lua code,
83 and can register C&nbsp;functions to be called by Lua code.
94 at Lua's official web site, <code>www.lua.org</code>.
147 including embedded zeros ('<code>\0</code>').
168 (See macro <code>LUA_32BITS</code> in file <code>luaconf.h</code>.)
209 undefined or unrepresentable numerical results, such as <code>0/0</code>.)
223 providing <code>a.name</code> as syntactic sugar for <code>a["name"]</code>.
240 The expressions <code>a[i]</code> and <code>a[j]</code>
242 if and only if <code>i</code> and <code>j</code> are raw equal
246 (e.g., <code>1.0 == 1</code>).
250 For instance, if you write <code>a[2.0] = true</code>,
252 integer <code>2</code>.
254 2 and "<code>2</code>" are different Lua values and therefore
268 The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
280 (that is, a name not bound to any declaration) <code>var</code>
281 is syntactically translated to <code>_ENV.var</code>.
283 an external local variable named <code>_ENV</code> (see <a href="#3.3.2">&sect;3.3.2</a>),
284 so <code>_ENV</code> itself is never a free name in a chunk.
288 Despite the existence of this external <code>_ENV</code> variable and
290 <code>_ENV</code> is a completely regular name.
293 Each reference to a free name uses the <code>_ENV</code> that is
299 Any table used as the value of <code>_ENV</code> is called an <em>environment</em>.
305 In Lua, the global variable <a href="#pdf-_G"><code>_G</code></a> is initialized with this same val…
306 (<a href="#pdf-_G"><code>_G</code></a> is never used internally.)
311 the default value for its <code>_ENV</code> upvalue
312 is the global environment (see <a href="#pdf-load"><code>load</code></a>).
314 free names in Lua code refer to entries in the global environment
318 You can use <a href="#pdf-load"><code>load</code></a> (or <a href="#pdf-loadfile"><code>loadfile</c…
331 all Lua actions start from C&nbsp;code in the host program
334 the <code>lua</code> application is the host program.)
343 Lua code can explicitly generate an error by calling the
344 <a href="#pdf-error"><code>error</code></a> function.
346 you can use <a href="#pdf-pcall"><code>pcall</code></a> or <a href="#pdf-xpcall"><code>xpcall</code
361 When you use <a href="#pdf-xpcall"><code>xpcall</code></a> or <a href="#lua_pcall"><code>lua_pcall<…
392 Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
401 In the previous example, the key is "<code>__add</code>"
409 using the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.
410 …s metamethods in metatables using a raw access (see <a href="#pdf-rawget"><code>rawget</code></a>).
411 So, to retrieve the metamethod for event <code>ev</code> in object <code>o</code>,
412 Lua does the equivalent to the following code:
420 using the <a href="#pdf-setmetatable"><code>setmetatable</code></a> function.
421 You cannot change the metatable of other types from Lua code
462 <li><b><code>__add</code>: </b>
463 the addition (<code>+</code>) operation.
468 If that operand does not define a metamethod for <code>__add</code>,
479 <li><b><code>__sub</code>: </b>
480 the subtraction (<code>-</code>) operation.
484 <li><b><code>__mul</code>: </b>
485 the multiplication (<code>*</code>) operation.
489 <li><b><code>__div</code>: </b>
490 the division (<code>/</code>) operation.
494 <li><b><code>__mod</code>: </b>
495 the modulo (<code>%</code>) operation.
499 <li><b><code>__pow</code>: </b>
500 the exponentiation (<code>^</code>) operation.
504 <li><b><code>__unm</code>: </b>
505 the negation (unary <code>-</code>) operation.
509 <li><b><code>__idiv</code>: </b>
510 the floor division (<code>//</code>) operation.
514 <li><b><code>__band</code>: </b>
515 the bitwise AND (<code>&amp;</code>) operation.
522 <li><b><code>__bor</code>: </b>
523 the bitwise OR (<code>|</code>) operation.
527 <li><b><code>__bxor</code>: </b>
528 the bitwise exclusive OR (binary <code>~</code>) operation.
532 <li><b><code>__bnot</code>: </b>
533 the bitwise NOT (unary <code>~</code>) operation.
537 <li><b><code>__shl</code>: </b>
538 the bitwise left shift (<code>&lt;&lt;</code>) operation.
542 <li><b><code>__shr</code>: </b>
543 the bitwise right shift (<code>&gt;&gt;</code>) operation.
547 <li><b><code>__concat</code>: </b>
548 the concatenation (<code>..</code>) operation.
555 <li><b><code>__len</code>: </b>
556 the length (<code>#</code>) operation.
569 <li><b><code>__eq</code>: </b>
570 the equal (<code>==</code>) operation.
578 <li><b><code>__lt</code>: </b>
579 the less than (<code>&lt;</code>) operation.
586 <li><b><code>__le</code>: </b>
587 the less equal (<code>&lt;=</code>) operation.
590 First, Lua looks for the <code>__le</code> metamethod in both operands,
593 then it will try the <code>__lt</code> metamethod,
594 assuming that <code>a &lt;= b</code> is equivalent to <code>not (b &lt; a)</code>.
597 (This use of the <code>__lt</code> event can be removed in future versions;
598 it is also slower than a real <code>__le</code> metamethod.)
601 <li><b><code>__index</code>: </b>
602 The indexing access operation <code>table[key]</code>.
603 This event happens when <code>table</code> is not a table or
604 when <code>key</code> is not present in <code>table</code>.
605 The metamethod is looked up in <code>table</code>.
612 it is called with <code>table</code> and <code>key</code> as arguments,
617 the final result is the result of indexing this table with <code>key</code>.
622 <li><b><code>__newindex</code>: </b>
623 The indexing assignment <code>table[key] = value</code>.
625 this event happens when <code>table</code> is not a table or
626 when <code>key</code> is not present in <code>table</code>.
627 The metamethod is looked up in <code>table</code>.
634 it is called with <code>table</code>, <code>key</code>, and <code>value</code> as arguments.
642 Whenever there is a <code>__newindex</code> metamethod,
645 the metamethod itself can call <a href="#pdf-rawset"><code>rawset</code></a>
649 <li><b><code>__call</code>: </b>
650 The call operation <code>func(args)</code>.
652 (that is, <code>func</code> is not a function).
653 The metamethod is looked up in <code>func</code>.
655 the metamethod is called with <code>func</code> as its first argument,
656 followed by the arguments of the original call (<code>args</code>).
667 In particular, the <code>__gc</code> metamethod works only when this order
676 (e.g., <a href="#pdf-tostring"><code>tostring</code></a>)
742 You can change these numbers by calling <a href="#lua_gc"><code>lua_gc</code></a> in C
743 or <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> in Lua.
767 and the metatable has a field indexed by the string "<code>__gc</code>".
768 Note that if you set a metatable without a <code>__gc</code> field
780 it checks the object's <code>__gc</code> metamethod:
795 the execution of the regular code.
816 When you close a state (see <a href="#lua_close"><code>lua_close</code></a>),
846 <code>__mode</code> field of its metatable.
847 If the <code>__mode</code> field is a string containing the character&nbsp;'<code>k</code>',
849 If <code>__mode</code> contains '<code>v</code>',
917 You create a coroutine by calling <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
920 The <code>create</code> function only creates a new coroutine and
926 You execute a coroutine by calling <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a…
927 When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
929 a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
932 Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are pas…
944 <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>true</b>,
946 In case of errors, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>fal…
951 A coroutine yields by calling <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
953 the corresponding <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns immedia…
957 In the case of a yield, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> also retu…
958 plus any values passed to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
961 with the call to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a> returning any extra
962 arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
966 Like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
967 the <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function also creates a coroutine,
971 go as extra arguments to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
972 …utine.wrap"><code>coroutine.wrap</code></a> returns all the values returned by <a href="#pdf-corou…
973 except the first one (the boolean error code).
974 Unlike <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
975 <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> does not catch errors;
981 consider the following code:
1018 …ee functions <a href="#lua_newthread"><code>lua_newthread</code></a>, <a href="#lua_resume"><code>…
1019 and <a href="#lua_yield"><code>lua_yield</code></a>.
1082 <code>and</code> is a reserved word, but <code>And</code> and <code>AND</code>
1087 one or more uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>).
1105 '<code>\a</code>' (bell),
1106 '<code>\b</code>' (backspace),
1107 '<code>\f</code>' (form feed),
1108 '<code>\n</code>' (newline),
1109 '<code>\r</code>' (carriage return),
1110 '<code>\t</code>' (horizontal tab),
1111 '<code>\v</code>' (vertical tab),
1112 '<code>\\</code>' (backslash),
1113 '<code>\"</code>' (quotation mark [double quote]),
1114 and '<code>\'</code>' (apostrophe [single quote]).
1117 The escape sequence '<code>\z</code>' skips the following span
1131 with the escape sequence <code>\x<em>XX</em></code>,
1133 or with the escape sequence <code>\<em>ddd</em></code>,
1142 the escape sequence <code>\u{<em>XXX</em>}</code>
1145 representing the character code point.
1154 So, an opening long bracket of level&nbsp;0 is written as <code>[[</code>,
1155 an opening long bracket of level&nbsp;1 is written as <code>[=[</code>,
1159 a closing long bracket of level&nbsp;4 is written as <code>]====]</code>.
1177 (in which '<code>a</code>' is coded as&nbsp;97,
1178 newline is coded as&nbsp;10, and '<code>1</code>' is coded as&nbsp;49),
1207 marked by a letter '<code>e</code>' or '<code>E</code>'.
1209 which start with <code>0x</code> or <code>0X</code>.
1212 marked by a letter '<code>p</code>' or '<code>P</code>'.
1231 A <em>comment</em> starts with a double hyphen (<code>--</code>)
1233 If the text immediately after <code>--</code> is not an opening long bracket,
1238 Long comments are frequently used to disable code temporarily.
1286 The syntax <code>var.Name</code> is just syntactic sugar for
1287 <code>var["Name"]</code>:
1294 An access to a global variable <code>x</code>
1295 is equivalent to <code>_ENV.x</code>.
1297 <code>_ENV</code> is never a global name (see <a href="#2.2">&sect;2.2</a>).
1395 scope of an external local variable called <code>_ENV</code> (see <a href="#2.2">&sect;2.2</a>).
1396 The resulting function always has <code>_ENV</code> as its only upvalue,
1404 precompiling the chunk's code into instructions for a virtual machine,
1405 and then Lua executes the compiled code
1411 see program <code>luac</code> and function <a href="#pdf-string.dump"><code>string.dump</code></a> …
1413 …tically detects the file type and acts accordingly (see <a href="#pdf-load"><code>load</code></a>).
1453 Thus the code
1459 sets <code>a[3]</code> to 20, without affecting <code>a[4]</code>
1460 because the <code>i</code> in <code>a[i]</code> is evaluated (to 3)
1467 exchanges the values of <code>x</code> and <code>y</code>,
1473 cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>.
1477 An assignment to a global name <code>x = val</code>
1479 <code>_ENV.x = val</code> (see <a href="#2.2">&sect;2.2</a>).
1579 as in the idiom <code>do return end</code>,
1595 The numerical <b>for</b> loop repeats a block of code while a
1610 is equivalent to the code:
1640 <code><em>var</em></code>, <code><em>limit</em></code>, and <code><em>step</em></code> are invisibl…
1654 The loop variable <code>v</code> is local to the loop body.
1677 is equivalent to the code:
1695 <code><em>explist</em></code> is evaluated only once.
1702 <code><em>f</em></code>, <code><em>s</em></code>, and <code><em>var</em></code> are invisible varia…
1711 The loop variables <code><em>var_i</em></code> are local to the loop;
1787 denoted by three dots ('<code>...</code>'), can only be used when
1843 <code>(f(x,y,z))</code> is always a single value,
1844 even if <code>f</code> returns several values.
1845 (The value of <code>(f(x,y,z))</code> is the first value returned by <code>f</code>
1846 or <b>nil</b> if <code>f</code> does not return any values.)
1854 <li><b><code>+</code>: </b>addition</li>
1855 <li><b><code>-</code>: </b>subtraction</li>
1856 <li><b><code>*</code>: </b>multiplication</li>
1857 <li><b><code>/</code>: </b>float division</li>
1858 <li><b><code>//</code>: </b>floor division</li>
1859 <li><b><code>%</code>: </b>modulo</li>
1860 <li><b><code>^</code>: </b>exponentiation</li>
1861 <li><b><code>-</code>: </b>unary minus</li>
1880 Exponentiation and float division (<code>/</code>)
1883 Exponentiation uses the ISO&nbsp;C function <code>pow</code>,
1888 Floor division (<code>//</code>) is a division
1912 <li><b><code>&amp;</code>: </b>bitwise AND</li>
1913 <li><b><code>&#124;</code>: </b>bitwise OR</li>
1914 <li><b><code>~</code>: </b>bitwise exclusive OR</li>
1915 <li><b><code>&gt;&gt;</code>: </b>right shift</li>
1916 <li><b><code>&lt;&lt;</code>: </b>left shift</li>
1917 <li><b><code>~</code>: </b>unary bitwise NOT</li>
1998 use the <code>format</code> function from the string library
1999 (see <a href="#pdf-string.format"><code>string.format</code></a>).
2009 <li><b><code>==</code>: </b>equality</li>
2010 <li><b><code>~=</code>: </b>inequality</li>
2011 <li><b><code>&lt;</code>: </b>less than</li>
2012 <li><b><code>&gt;</code>: </b>greater than</li>
2013 <li><b><code>&lt;=</code>: </b>less or equal</li>
2014 <li><b><code>&gt;=</code>: </b>greater or equal</li>
2020 Equality (<code>==</code>) first compares the type of its operands.
2050 Thus, <code>"0"==0</code> evaluates to <b>false</b>,
2051 and <code>t[0]</code> and <code>t["0"]</code> denote different
2056 The operator <code>~=</code> is exactly the negation of equality (<code>==</code>).
2068 A comparison <code>a &gt; b</code> is translated to <code>b &lt; a</code>
2069 and <code>a &gt;= b</code> is translated to <code>b &lt;= a</code>.
2113 <code>--&gt;</code> indicates the result of the preceding expression.)
2121 denoted by two dots ('<code>..</code>').
2124 Otherwise, the <code>__concat</code> metamethod is called (see <a href="#2.4">&sect;2.4</a>).
2133 The length operator is denoted by the unary prefix operator <code>#</code>.
2145 A <em>border</em> in a table <code>t</code> is any natural number
2159 For instance, the table <code>{10, 20, 30, 40, 50}</code> is a sequence,
2161 The table <code>{10, 20, 30, nil, 50}</code> has two borders (3 and 5),
2163 The table <code>{nil, 20, 30, nil, nil, 60, nil}</code>
2166 The table <code>{}</code> is a sequence with border 0.
2172 When <code>t</code> is a sequence,
2173 <code>#t</code> returns its only border,
2175 When <code>t</code> is not a sequence,
2176 <code>#t</code> can return any of its borders.
2191 any value but strings through the <code>__len</code> metamethod (see <a href="#2.4">&sect;2.4</a>).
2217 The concatenation ('<code>..</code>') and exponentiation ('<code>^</code>')
2240 Each field of the form <code>[exp1] = exp2</code> adds to the new table an entry
2241 with key <code>exp1</code> and value <code>exp2</code>.
2242 A field of the form <code>name = exp</code> is equivalent to
2243 <code>["name"] = exp</code>.
2244 Finally, fields of the form <code>exp</code> are equivalent to
2245 <code>[i] = exp</code>, where <code>i</code> are consecutive integers
2275 If the last field in the list has the form <code>exp</code>
2283 as a convenience for machine-generated code.
2313 A call <code>v:name(<em>args</em>)</code>
2314 is syntactic sugar for <code>v.name(v,<em>args</em>)</code>,
2315 except that <code>v</code> is evaluated only once.
2327 A call of the form <code>f{<em>fields</em>}</code> is
2328 syntactic sugar for <code>f({<em>fields</em>})</code>;
2330 A call of the form <code>f'<em>string</em>'</code>
2331 (or <code>f"<em>string</em>"</code> or <code>f[[<em>string</em>]]</code>)
2332 is syntactic sugar for <code>f('<em>string</em>')</code>;
2337 A call of the form <code>return <em>functioncall</em></code> is called
2418 contains references to <code>f</code>.)
2443 which is indicated by three dots ('<code>...</code>')
2502 that is, functions that have an implicit extra parameter <code>self</code>.
2545 Notice that, in a declaration like <code>local x = x</code>,
2546 the new <code>x</code> being declared is not in scope yet,
2547 and so the second <code>x</code> refers to the outside variable.
2574 Each of these closures uses a different <code>y</code> variable,
2575 while all of them share the same <code>x</code>.
2589 are declared in the header file <a name="pdf-lua.h"><code>lua.h</code></a>.
2605 with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a> defined.
2618 The type <a href="#lua_State"><code>lua_State</code></a> (despite its name) refers to a thread.
2625 every function in the library, except to <a href="#lua_newstate"><code>lua_newstate</code></a>,
2648 to be returned to the caller (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
2679 You can use the function <a href="#lua_checkstack"><code>lua_checkstack</code></a>
2686 at least <a name="pdf-LUA_MINSTACK"><code>LUA_MINSTACK</code></a> extra slots.
2687 <code>LUA_MINSTACK</code> is defined as 20,
2689 unless your code has loops pushing elements onto the stack.
2694 without a fixed number of results (see <a href="#lua_call"><code>lua_call</code></a>),
2698 you should use <a href="#lua_checkstack"><code>lua_checkstack</code></a>.
2715 (<code>1 &le; abs(index) &le; top</code>)
2718 which represent some positions that are accessible to C&nbsp;code
2748 contains a value of a virtual type <a name="pdf-LUA_TNONE"><code>LUA_TNONE</code></a>,
2761 (see <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a>);
2770 <a href="#lua_upvalueindex"><code>lua_upvalueindex</code></a>.
2772 <code>lua_upvalueindex(1)</code>, and so on.
2773 Any access to <code>lua_upvalueindex(<em>n</em>)</code>,
2788 a predefined table that can be used by any C&nbsp;code to
2791 <a name="pdf-LUA_REGISTRYINDEX"><code>LUA_REGISTRYINDEX</code></a>.
2797 or a light userdata with the address of a C&nbsp;object in your code,
2798 or any Lua object created by your code.
2806 by the reference mechanism (see <a href="#luaL_ref"><code>luaL_ref</code></a>)
2815 defined as constants in <code>lua.h</code>.
2819 <li><b><a name="pdf-LUA_RIDX_MAINTHREAD"><code>LUA_RIDX_MAINTHREAD</code></a>: </b> At this index t…
2824 <li><b><a name="pdf-LUA_RIDX_GLOBALS"><code>LUA_RIDX_GLOBALS</code></a>: </b> At this index the reg…
2835 Internally, Lua uses the C <code>longjmp</code> facility to handle errors.
2837 search for <code>LUAI_THROW</code> in the source code for details.)
2842 A <em>protected environment</em> uses <code>setjmp</code>
2848 … C&nbsp;function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
2860 Lua calls a <em>panic function</em> (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>)
2861 and then calls <code>abort</code>,
2878 when C code operates on other Lua states
2881 the result of <a href="#lua_newthread"><code>lua_newthread</code></a>),
2899 Internally, Lua uses the C <code>longjmp</code> facility to yield a coroutine.
2900 Therefore, if a C&nbsp;function <code>foo</code> calls an API function
2903 Lua cannot return to <code>foo</code> any more,
2904 because the <code>longjmp</code> removes its frame from the C stack.
2911 …#lua_yieldk"><code>lua_yieldk</code></a>, <a href="#lua_callk"><code>lua_callk</code></a>, and <a …
2913 (as a parameter named <code>k</code>) to continue execution after a yield.
2923 (This can happen when the callee function is <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
2924 …unction is either <a href="#lua_callk"><code>lua_callk</code></a> or <a href="#lua_pcallk"><code>l…
2947 ... /* code 1 */
2949 ... /* code 2 */
2953 the Lua code being run by <a href="#lua_pcall"><code>lua_pcall</code></a> to yield.
2958 ... /* code 2 */
2962 ... /* code 1 */
2966 In the above code,
2967 the new function <code>k</code> is a
2968 <em>continuation function</em> (with type <a href="#lua_KFunction"><code>lua_KFunction</code></a>),
2970 was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>.
2971 Now, we must inform Lua that it must call <code>k</code> if the Lua code
2972 being executed by <a href="#lua_pcall"><code>lua_pcall</code></a> gets interrupted in some way
2974 so we rewrite the code as here,
2975 replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcallk"><code>lua_pcallk…
2979 ... /* code 1 */
2987 <a href="#lua_pcallk"><code>lua_pcallk</code></a> (and <a href="#lua_callk"><code>lua_callk</code><…
2995 the final status of the call plus the context value (<code>ctx</code>) that
2996 was passed originally to <a href="#lua_pcallk"><code>lua_pcallk</code></a>.
3000 For <a href="#lua_pcallk"><code>lua_pcallk</code></a>,
3001 the status is the same value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code
3002 except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after a y…
3003 (instead of <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>).
3004 For <a href="#lua_yieldk"><code>lua_yieldk</code></a> and <a href="#lua_callk"><code>lua_callk</cod…
3005 the status is always <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when Lua calls the continu…
3009 Similarly, when using <a href="#lua_callk"><code>lua_callk</code></a>,
3011 with <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> as the status.
3012 (For <a href="#lua_yieldk"><code>lua_yieldk</code></a>, there is not much point in calling
3014 because <a href="#lua_yieldk"><code>lua_yieldk</code></a> usually does not return.)
3023 after a <a href="#lua_callk"><code>lua_callk</code></a> the function and its arguments are
3043 The first field, <code>o</code>,
3045 The second field, <code>p</code>,
3048 A field in the form <code>x|y</code> means the function can push (or pop)
3049 <code>x</code> or <code>y</code> elements,
3051 an interrogation mark '<code>?</code>' means that
3055 The third field, <code>x</code>,
3057 '<code>-</code>' means the function never raises any error;
3058 '<code>m</code>' means the function may raise out-of-memory errors
3059 and errors running a <code>__gc</code> metamethod;
3060 '<code>e</code>' means the function may raise any errors
3061 (it can run arbitrary Lua code,
3063 '<code>v</code>' means the function may raise an error on purpose.
3067 <hr><h3><a name="lua_absindex"><code>lua_absindex</code></a></h3><p>
3072 Converts the acceptable index <code>idx</code>
3080 <hr><h3><a name="lua_Alloc"><code>lua_Alloc</code></a></h3>
3089 functionality similar to <code>realloc</code>,
3092 <code>ud</code>, an opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>;
3093 <code>ptr</code>, a pointer to the block being allocated/reallocated/freed;
3094 <code>osize</code>, the original size of the block or some code about what
3096 and <code>nsize</code>, the new size of the block.
3100 When <code>ptr</code> is not <code>NULL</code>,
3101 <code>osize</code> is the size of the block pointed by <code>ptr</code>,
3106 When <code>ptr</code> is <code>NULL</code>,
3107 <code>osize</code> encodes the kind of object that Lua is allocating.
3108 <code>osize</code> is any of
3109 …RING"><code>LUA_TSTRING</code></a>, <a href="#pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>, <a href…
3110 <a href="#pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>, or <a href="#pdf-LUA_TTHREAD"><code>LU…
3112 When <code>osize</code> is some other value,
3121 When <code>nsize</code> is zero,
3122 the allocator must behave like <code>free</code>
3123 and return <code>NULL</code>.
3127 When <code>nsize</code> is not zero,
3128 the allocator must behave like <code>realloc</code>.
3129 The allocator returns <code>NULL</code>
3132 <code>osize &gt;= nsize</code>.
3137 It is used in the auxiliary library by <a href="#luaL_newstate"><code>luaL_newstate</code></a>.
3152 that <code>free(NULL)</code> has no effect and that
3153 <code>realloc(NULL,size)</code> is equivalent to <code>malloc(size)</code>.
3154 This code assumes that <code>realloc</code> does not fail when shrinking a block.
3162 <hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p>
3177 The value of <code>op</code> must be one of the following constants:
3181 <li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>: </b> performs addition (<code>+</code>)<…
3182 <li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>: </b> performs subtraction (<code>-</code
3183 <li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>: </b> performs multiplication (<code>*</c…
3184 <li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>: </b> performs float division (<code>/</c…
3185 <li><b><a name="pdf-LUA_OPIDIV"><code>LUA_OPIDIV</code></a>: </b> performs floor division (<code>//…
3186 <li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>: </b> performs modulo (<code>%</code>)</l…
3187 <li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>: </b> performs exponentiation (<code>^</c…
3188 <li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>: </b> performs mathematical negation (una…
3189 <li><b><a name="pdf-LUA_OPBNOT"><code>LUA_OPBNOT</code></a>: </b> performs bitwise NOT (<code>~</co…
3190 <li><b><a name="pdf-LUA_OPBAND"><code>LUA_OPBAND</code></a>: </b> performs bitwise AND (<code>&amp;…
3191 <li><b><a name="pdf-LUA_OPBOR"><code>LUA_OPBOR</code></a>: </b> performs bitwise OR (<code>|</code>…
3192 <li><b><a name="pdf-LUA_OPBXOR"><code>LUA_OPBXOR</code></a>: </b> performs bitwise exclusive OR (<c…
3193 <li><b><a name="pdf-LUA_OPSHL"><code>LUA_OPSHL</code></a>: </b> performs left shift (<code>&lt;&lt;…
3194 <li><b><a name="pdf-LUA_OPSHR"><code>LUA_OPSHR</code></a>: </b> performs right shift (<code>&gt;&gt…
3201 <hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
3212 <hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
3226 Finally you call <a href="#lua_call"><code>lua_call</code></a>;
3227 <code>nargs</code> is the number of arguments that you pushed onto the stack.
3231 The number of results is adjusted to <code>nresults</code>,
3232 unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
3243 (with a <code>longjmp</code>).
3248 equivalent to this Lua code:
3265 Note that the code above is <em>balanced</em>:
3273 <hr><h3><a name="lua_callk"><code>lua_callk</code></a></h3><p>
3282 This function behaves exactly like <a href="#lua_call"><code>lua_call</code></a>,
3289 <hr><h3><a name="lua_CFunction"><code>lua_CFunction</code></a></h3>
3303 <code>lua_gettop(L)</code> returns the number of arguments received by the function.
3305 and its last argument is at index <code>lua_gettop(L)</code>.
3340 <hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
3345 Ensures that the stack has space for at least <code>n</code> extra slots
3346 (that is, that you can safely push up to <code>n</code> values into it).
3360 <hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
3378 <hr><h3><a name="lua_compare"><code>lua_compare</code></a></h3><p>
3384 Returns 1 if the value at index <code>index1</code> satisfies <code>op</code>
3385 when compared with the value at index <code>index2</code>,
3393 The value of <code>op</code> must be one of the following constants:
3397 <li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>: </b> compares for equality (<code>==</code
3398 <li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>: </b> compares for less than (<code>&lt;</c…
3399 <li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code>&lt…
3406 <hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
3411 Concatenates the <code>n</code> values at the top of the stack,
3413 If <code>n</code>&nbsp;is&nbsp;1, the result is the single value on the stack
3415 if <code>n</code> is 0, the result is the empty string.
3423 <hr><h3><a name="lua_copy"><code>lua_copy</code></a></h3><p>
3428 Copies the element at index <code>fromidx</code>
3429 into the valid index <code>toidx</code>,
3437 <hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
3443 Parameter <code>narr</code> is a hint for how many elements the table
3445 parameter <code>nrec</code> is a hint for how many other elements
3450 Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</code></a>.
3456 <hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
3470 <a href="#lua_dump"><code>lua_dump</code></a> calls function <code>writer</code> (see <a href="#lua…
3471 with the given <code>data</code>
3476 If <code>strip</code> is true,
3483 The value returned is the error code returned by the last
3495 <hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
3504 (see <a href="#luaL_error"><code>luaL_error</code></a>).
3510 <hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
3520 according to the value of the parameter <code>what</code>:
3524 <li><b><code>LUA_GCSTOP</code>: </b>
3528 <li><b><code>LUA_GCRESTART</code>: </b>
3532 <li><b><code>LUA_GCCOLLECT</code>: </b>
3536 <li><b><code>LUA_GCCOUNT</code>: </b>
3540 <li><b><code>LUA_GCCOUNTB</code>: </b>
3545 <li><b><code>LUA_GCSTEP</code>: </b>
3549 <li><b><code>LUA_GCSETPAUSE</code>: </b>
3550 sets <code>data</code> as the new value
3555 <li><b><code>LUA_GCSETSTEPMUL</code>: </b>
3556 sets <code>data</code> as the new value for the <em>step multiplier</em> of
3561 <li><b><code>LUA_GCISRUNNING</code>: </b>
3570 see <a href="#pdf-collectgarbage"><code>collectgarbage</code></a>.
3576 <hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
3582 If <code>ud</code> is not <code>NULL</code>, Lua stores in <code>*ud</code> the
3589 <hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
3594 Pushes onto the stack the value <code>t[k]</code>,
3595 where <code>t</code> is the value at the given index.
3607 <hr><h3><a name="lua_getextraspace"><code>lua_getextraspace</code></a></h3><p>
3626 (See <code>LUA_EXTRASPACE</code> in <code>luaconf.h</code>.)
3632 <hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
3637 Pushes onto the stack the value of the global <code>name</code>.
3644 <hr><h3><a name="lua_geti"><code>lua_geti</code></a></h3><p>
3649 Pushes onto the stack the value <code>t[i]</code>,
3650 where <code>t</code> is the value at the given index.
3662 <hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
3676 <hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
3681 Pushes onto the stack the value <code>t[k]</code>,
3682 where <code>t</code> is the value at the given index
3683 and <code>k</code> is the value at the top of the stack.
3700 <hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
3714 <hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p>
3730 <hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
3744 <hr><h3><a name="lua_Integer"><code>lua_Integer</code></a></h3>
3752 By default this type is <code>long long</code>,
3754 but that can be changed to <code>long</code> or <code>int</code>
3756 (See <code>LUA_INT_TYPE</code> in <code>luaconf.h</code>.)
3761 <a name="pdf-LUA_MININTEGER"><code>LUA_MININTEGER</code></a> and <a name="pdf-LUA_MAXINTEGER"><code
3768 <hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
3780 <hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
3792 <hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
3804 <hr><h3><a name="lua_isinteger"><code>lua_isinteger</code></a></h3><p>
3817 <hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
3829 <hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
3841 <hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
3853 <hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
3866 <hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
3879 <hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
3892 <hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
3904 <hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
3916 <hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
3928 <hr><h3><a name="lua_isyieldable"><code>lua_isyieldable</code></a></h3><p>
3940 <hr><h3><a name="lua_KContext"><code>lua_KContext</code></a></h3>
3946 This type is defined as <code>intptr_t</code>
3947 when <code>intptr_t</code> is available,
3949 Otherwise, it is defined as <code>ptrdiff_t</code>.
3955 <hr><h3><a name="lua_KFunction"><code>lua_KFunction</code></a></h3>
3965 <hr><h3><a name="lua_len"><code>lua_len</code></a></h3><p>
3971 It is equivalent to the '<code>#</code>' operator in Lua (see <a href="#3.4.7">&sect;3.4.7</a>) and
3979 <hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
3990 <code>lua_load</code> pushes the compiled chunk as a Lua
3996 The return values of <code>lua_load</code> are:
4000 <li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a>: </b> no errors;</li>
4002 <li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>: </b>
4005 <li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
4008 <li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
4009 error while running a <code>__gc</code> metamethod.
4017 The <code>lua_load</code> function uses a user-supplied <code>reader</code> function
4018 to read the chunk (see <a href="#lua_Reader"><code>lua_Reader</code></a>).
4019 The <code>data</code> argument is an opaque value passed to the reader function.
4023 The <code>chunkname</code> argument gives a name to the chunk,
4028 <code>lua_load</code> automatically detects whether the chunk is text or binary
4029 and loads it accordingly (see program <code>luac</code>).
4030 The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>,
4032 a <code>NULL</code> value is equivalent to the string "<code>bt</code>".
4036 <code>lua_load</code> uses the stack internally,
4044 stored at index <code>LUA_RIDX_GLOBALS</code> in the registry (see <a href="#4.5">&sect;4.5</a>).
4046 this upvalue will be the <code>_ENV</code> variable (see <a href="#2.2">&sect;2.2</a>).
4053 <hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
4059 Returns <code>NULL</code> if it cannot create the thread or the state
4061 The argument <code>f</code> is the allocator function;
4063 through this function (see <a href="#lua_Alloc"><code>lua_Alloc</code></a>).
4064 The second argument, <code>ud</code>, is an opaque pointer that Lua
4071 <hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
4077 It is equivalent to <code>lua_createtable(L, 0, 0)</code>.
4083 <hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
4089 and returns a pointer to a <a href="#lua_State"><code>lua_State</code></a> that represents this new…
4104 <hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
4118 <hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
4127 then <a href="#lua_next"><code>lua_next</code></a> returns 0 (and pushes nothing).
4148 do not call <a href="#lua_tolstring"><code>lua_tolstring</code></a> directly on a key,
4150 Recall that <a href="#lua_tolstring"><code>lua_tolstring</code></a> may change
4152 this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
4156 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
4163 <hr><h3><a name="lua_Number"><code>lua_Number</code></a></h3>
4173 (See <code>LUA_FLOAT_TYPE</code> in <code>luaconf.h</code>.)
4179 <hr><h3><a name="lua_numbertointeger"><code>lua_numbertointeger</code></a></h3>
4184 This macro assumes that <code>n</code> has an integral value.
4186 it is converted to an integer and assigned to <code>*p</code>.
4201 <hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
4210 Both <code>nargs</code> and <code>nresults</code> have the same meaning as
4211 in <a href="#lua_call"><code>lua_call</code></a>.
4213 <a href="#lua_pcall"><code>lua_pcall</code></a> behaves exactly like <a href="#lua_call"><code>lua_…
4215 <a href="#lua_pcall"><code>lua_pcall</code></a> catches it,
4217 and returns an error code.
4218 Like <a href="#lua_call"><code>lua_call</code></a>,
4219 <a href="#lua_pcall"><code>lua_pcall</code></a> always removes the function
4224 If <code>msgh</code> is 0,
4227 Otherwise, <code>msgh</code> is the stack index of a
4233 returned on the stack by <a href="#lua_pcall"><code>lua_pcall</code></a>.
4239 Such information cannot be gathered after the return of <a href="#lua_pcall"><code>lua_pcall</code>…
4244 The <a href="#lua_pcall"><code>lua_pcall</code></a> function returns one of the following constants
4245 (defined in <code>lua.h</code>):
4249 <li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b>
4252 <li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>: </b>
4256 <li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
4261 <li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>: </b>
4265 <li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
4266 error while running a <code>__gc</code> metamethod.
4277 <hr><h3><a name="lua_pcallk"><code>lua_pcallk</code></a></h3><p>
4287 This function behaves exactly like <a href="#lua_pcall"><code>lua_pcall</code></a>,
4294 <hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
4299 Pops <code>n</code> elements from the stack.
4305 <hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
4310 Pushes a boolean value with value <code>b</code> onto the stack.
4316 <hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
4332 Then <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a>
4334 with the argument <code>n</code> telling how many values will be
4336 <a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.
4340 The maximum value for <code>n</code> is 255.
4344 When <code>n</code> is zero,
4353 <hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
4360 and pushes onto the stack a Lua value of type <code>function</code> that,
4367 and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
4373 <hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
4380 It is similar to the ISO&nbsp;C function <code>sprintf</code>,
4395 '<code>%%</code>' (inserts the character '<code>%</code>'),
4396 '<code>%s</code>' (inserts a zero-terminated string, with no size restrictions),
4397 '<code>%f</code>' (inserts a <a href="#lua_Number"><code>lua_Number</code></a>),
4398 '<code>%I</code>' (inserts a <a href="#lua_Integer"><code>lua_Integer</code></a>),
4399 '<code>%p</code>' (inserts a pointer as a hexadecimal numeral),
4400 '<code>%d</code>' (inserts an <code>int</code>),
4401 '<code>%c</code>' (inserts an <code>int</code> as a one-byte character), and
4402 '<code>%U</code>' (inserts a <code>long int</code> as a UTF-8 byte sequence).
4416 <hr><h3><a name="lua_pushglobaltable"><code>lua_pushglobaltable</code></a></h3><p>
4427 <hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
4432 Pushes an integer with value <code>n</code> onto the stack.
4438 <hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
4448 A <em>light userdata</em> represents a pointer, a <code>void*</code>.
4459 <hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
4464 This macro is equivalent to <a href="#lua_pushstring"><code>lua_pushstring</code></a>,
4465 but should be used only when <code>s</code> is a literal string.
4471 <hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
4476 Pushes the string pointed to by <code>s</code> with size <code>len</code>
4479 so the memory at <code>s</code> can be freed or reused immediately after
4492 <hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
4503 <hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
4508 Pushes a float with value <code>n</code> onto the stack.
4514 <hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
4519 Pushes the zero-terminated string pointed to by <code>s</code>
4522 so the memory at <code>s</code> can be freed or reused immediately after
4531 If <code>s</code> is <code>NULL</code>, pushes <b>nil</b> and returns <code>NULL</code>.
4537 <hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
4542 Pushes the thread represented by <code>L</code> onto the stack.
4549 <hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
4561 <hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
4568 …alent to <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>, except that it receives a <c…
4575 <hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
4580 Returns 1 if the two values in indices <code>index1</code> and
4581 <code>index2</code> are primitively equal
4582 (that is, without calling the <code>__eq</code> metamethod).
4590 <hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
4595 Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw access
4602 <hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
4607 Pushes onto the stack the value <code>t[n]</code>,
4608 where <code>t</code> is the table at the given index.
4610 that is, it does not invoke the <code>__index</code> metamethod.
4620 <hr><h3><a name="lua_rawgetp"><code>lua_rawgetp</code></a></h3><p>
4625 Pushes onto the stack the value <code>t[k]</code>,
4626 where <code>t</code> is the table at the given index and
4627 <code>k</code> is the pointer <code>p</code> represented as a light userdata.
4629 that is, it does not invoke the <code>__index</code> metamethod.
4639 <hr><h3><a name="lua_rawlen"><code>lua_rawlen</code></a></h3><p>
4646 for tables, this is the result of the length operator ('<code>#</code>')
4656 <hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
4661 Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw assignment
4668 <hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
4673 Does the equivalent of <code>t[i] = v</code>,
4674 where <code>t</code> is the table at the given index
4675 and <code>v</code> is the value at the top of the stack.
4681 that is, it does not invoke the <code>__newindex</code> metamethod.
4687 <hr><h3><a name="lua_rawsetp"><code>lua_rawsetp</code></a></h3><p>
4692 Does the equivalent of <code>t[p] = v</code>,
4693 where <code>t</code> is the table at the given index,
4694 <code>p</code> is encoded as a light userdata,
4695 and <code>v</code> is the value at the top of the stack.
4701 that is, it does not invoke <code>__newindex</code> metamethod.
4707 <hr><h3><a name="lua_Reader"><code>lua_Reader</code></a></h3>
4713 The reader function used by <a href="#lua_load"><code>lua_load</code></a>.
4715 <a href="#lua_load"><code>lua_load</code></a> calls the reader,
4716 passing along its <code>data</code> parameter.
4719 and set <code>size</code> to the block size.
4722 the reader must return <code>NULL</code> or set <code>size</code> to zero.
4729 <hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
4734 Sets the C&nbsp;function <code>f</code> as the new value of global <code>name</code>.
4745 <hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
4759 <hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
4773 <hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
4778 Starts and resumes a coroutine in the given thread <code>L</code>.
4784 then you call <a href="#lua_resume"><code>lua_resume</code></a>,
4785 with <code>nargs</code> being the number of arguments.
4787 When it returns, the stack contains all values passed to <a href="#lua_yield"><code>lua_yield</code
4789 <a href="#lua_resume"><code>lua_resume</code></a> returns
4790 <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the coroutine yields,
4791 <a href="#pdf-LUA_OK"><code>LUA_OK</code></a> if the coroutine finishes its execution
4793 or an error code in case of errors (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
4805 you remove any results from the last <a href="#lua_yield"><code>lua_yield</code></a>,
4807 be passed as results from <code>yield</code>,
4808 and then call <a href="#lua_resume"><code>lua_resume</code></a>.
4812 The parameter <code>from</code> represents the coroutine that is resuming <code>L</code>.
4814 this parameter can be <code>NULL</code>.
4820 <hr><h3><a name="lua_rotate"><code>lua_rotate</code></a></h3><p>
4825 Rotates the stack elements between the valid index <code>idx</code>
4827 The elements are rotated <code>n</code> positions in the direction of the top,
4828 for a positive <code>n</code>,
4829 or <code>-n</code> positions in the direction of the bottom,
4830 for a negative <code>n</code>.
4831 The absolute value of <code>n</code> must not be greater than the size
4840 <hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
4845 Changes the allocator function of a given state to <code>f</code>
4846 with user data <code>ud</code>.
4852 <hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
4857 Does the equivalent to <code>t[k] = v</code>,
4858 where <code>t</code> is the value at the given index
4859 and <code>v</code> is the value at the top of the stack.
4871 <hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
4877 sets it as the new value of global <code>name</code>.
4883 <hr><h3><a name="lua_seti"><code>lua_seti</code></a></h3><p>
4888 Does the equivalent to <code>t[n] = v</code>,
4889 where <code>t</code> is the value at the given index
4890 and <code>v</code> is the value at the top of the stack.
4902 <hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
4914 <hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
4919 Does the equivalent to <code>t[k] = v</code>,
4920 where <code>t</code> is the value at the given index,
4921 <code>v</code> is the value at the top of the stack,
4922 and <code>k</code> is the value just below the top.
4934 <hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
4943 If <code>index</code> is&nbsp;0, then all stack elements are removed.
4949 <hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p>
4961 <hr><h3><a name="lua_State"><code>lua_State</code></a></h3>
4974 every function in the library, except to <a href="#lua_newstate"><code>lua_newstate</code></a>,
4981 <hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
4986 Returns the status of the thread <code>L</code>.
4990 The status can be 0 (<a href="#pdf-LUA_OK"><code>LUA_OK</code></a>) for a normal thread,
4991 an error code if the thread finished the execution
4992 of a <a href="#lua_resume"><code>lua_resume</code></a> with an error,
4993 or <a name="pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the thread is suspended.
4997 You can only call functions in threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>.
4998 You can resume threads with status <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>
4999 (to start a new coroutine) or <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a>
5006 <hr><h3><a name="lua_stringtonumber"><code>lua_stringtonumber</code></a></h3><p>
5011 Converts the zero-terminated string <code>s</code> to a number,
5027 <hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
5035 <a href="#lua_toboolean"><code>lua_toboolean</code></a> returns true for any Lua value
5039 use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's type.)
5045 <hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
5052 otherwise, returns <code>NULL</code>.
5058 <hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
5063 …alent to <a href="#lua_tointegerx"><code>lua_tointegerx</code></a> with <code>isnum</code> equal t…
5069 <hr><h3><a name="lua_tointegerx"><code>lua_tointegerx</code></a></h3><p>
5075 to the signed integral type <a href="#lua_Integer"><code>lua_Integer</code></a>.
5078 otherwise, <code>lua_tointegerx</code> returns&nbsp;0.
5082 If <code>isnum</code> is not <code>NULL</code>,
5090 <hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
5096 If <code>len</code> is not <code>NULL</code>,
5097 it sets <code>*len</code> with the string length.
5099 otherwise, the function returns <code>NULL</code>.
5101 then <code>lua_tolstring</code> also
5103 (This change confuses <a href="#lua_next"><code>lua_next</code></a>
5104 when <code>lua_tolstring</code> is applied to keys during a table traversal.)
5108 <code>lua_tolstring</code> returns a pointer
5110 This string always has a zero ('<code>\0</code>')
5117 there is no guarantee that the pointer returned by <code>lua_tolstring</code>
5124 <hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
5129 …ivalent to <a href="#lua_tonumberx"><code>lua_tonumberx</code></a> with <code>isnum</code> equal t…
5135 <hr><h3><a name="lua_tonumberx"><code>lua_tonumberx</code></a></h3><p>
5141 …he C&nbsp;type <a href="#lua_Number"><code>lua_Number</code></a> (see <a href="#lua_Number"><code>…
5144 otherwise, <a href="#lua_tonumberx"><code>lua_tonumberx</code></a> returns&nbsp;0.
5148 If <code>isnum</code> is not <code>NULL</code>,
5156 <hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
5162 C&nbsp;pointer (<code>void*</code>).
5164 otherwise, <code>lua_topointer</code> returns <code>NULL</code>.
5176 <hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
5181 …uivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to…
5187 <hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
5193 (represented as <code>lua_State*</code>).
5195 otherwise, the function returns <code>NULL</code>.
5201 <hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
5210 Otherwise, returns <code>NULL</code>.
5216 <hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
5222 or <code>LUA_TNONE</code> for a non-valid (but acceptable) index.
5223 The types returned by <a href="#lua_type"><code>lua_type</code></a> are coded by the following cons…
5224 defined in <code>lua.h</code>:
5225 <a name="pdf-LUA_TNIL"><code>LUA_TNIL</code></a> (0),
5226 <a name="pdf-LUA_TNUMBER"><code>LUA_TNUMBER</code></a>,
5227 <a name="pdf-LUA_TBOOLEAN"><code>LUA_TBOOLEAN</code></a>,
5228 <a name="pdf-LUA_TSTRING"><code>LUA_TSTRING</code></a>,
5229 <a name="pdf-LUA_TTABLE"><code>LUA_TTABLE</code></a>,
5230 <a name="pdf-LUA_TFUNCTION"><code>LUA_TFUNCTION</code></a>,
5231 <a name="pdf-LUA_TUSERDATA"><code>LUA_TUSERDATA</code></a>,
5232 <a name="pdf-LUA_TTHREAD"><code>LUA_TTHREAD</code></a>,
5234 <a name="pdf-LUA_TLIGHTUSERDATA"><code>LUA_TLIGHTUSERDATA</code></a>.
5240 <hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
5245 Returns the name of the type encoded by the value <code>tp</code>,
5246 which must be one the values returned by <a href="#lua_type"><code>lua_type</code></a>.
5252 <hr><h3><a name="lua_Unsigned"><code>lua_Unsigned</code></a></h3>
5256 The unsigned version of <a href="#lua_Integer"><code>lua_Integer</code></a>.
5262 <hr><h3><a name="lua_upvalueindex"><code>lua_upvalueindex</code></a></h3><p>
5267 Returns the pseudo-index that represents the <code>i</code>-th upvalue of
5274 <hr><h3><a name="lua_version"><code>lua_version</code></a></h3><p>
5282 When called with a valid <a href="#lua_State"><code>lua_State</code></a>,
5284 When called with <code>NULL</code>,
5291 <hr><h3><a name="lua_Writer"><code>lua_Writer</code></a></h3>
5298 The type of the writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
5300 <a href="#lua_dump"><code>lua_dump</code></a> calls the writer,
5301 passing along the buffer to be written (<code>p</code>),
5302 its size (<code>sz</code>),
5303 and the <code>data</code> parameter supplied to <a href="#lua_dump"><code>lua_dump</code></a>.
5307 The writer returns an error code:
5309 any other value means an error and stops <a href="#lua_dump"><code>lua_dump</code></a> from
5316 <hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
5325 This function pops <code>n</code> values from the stack <code>from</code>,
5326 and pushes them onto the stack <code>to</code>.
5332 <hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
5337 This function is equivalent to <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
5341 the function calling <code>lua_yield</code>.
5347 <hr><h3><a name="lua_yieldk"><code>lua_yieldk</code></a></h3><p>
5359 When a C&nbsp;function calls <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
5361 and the call to <a href="#lua_resume"><code>lua_resume</code></a> that started this coroutine retur…
5362 The parameter <code>nresults</code> is the number of values from the stack
5363 that will be passed as results to <a href="#lua_resume"><code>lua_resume</code></a>.
5368 Lua calls the given continuation function <code>k</code> to continue
5372 with the <code>n</code> results removed and
5373 replaced by the arguments passed to <a href="#lua_resume"><code>lua_resume</code></a>.
5375 the continuation function receives the value <code>ctx</code>
5376 that was passed to <a href="#lua_yieldk"><code>lua_yieldk</code></a>.
5386 In that case, <code>lua_yieldk</code> should be called with no continuation
5387 (probably in the form of <a href="#lua_yield"><code>lua_yield</code></a>) and no results,
5419 <hr><h3><a name="lua_Debug"><code>lua_Debug</code></a></h3>
5441 <a href="#lua_getstack"><code>lua_getstack</code></a> fills only the private part
5443 To fill the other fields of <a href="#lua_Debug"><code>lua_Debug</code></a> with useful information,
5444 call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
5448 The fields of <a href="#lua_Debug"><code>lua_Debug</code></a> have the following meaning:
5452 <li><b><code>source</code>: </b>
5454 If <code>source</code> starts with a '<code>@</code>',
5456 the file name follows the '<code>@</code>'.
5457 If <code>source</code> starts with a '<code>=</code>',
5461 <code>source</code> is that string.
5464 <li><b><code>short_src</code>: </b>
5465 a "printable" version of <code>source</code>, to be used in error messages.
5468 <li><b><code>linedefined</code>: </b>
5472 <li><b><code>lastlinedefined</code>: </b>
5476 <li><b><code>what</code>: </b>
5477 the string <code>"Lua"</code> if the function is a Lua function,
5478 <code>"C"</code> if it is a C&nbsp;function,
5479 <code>"main"</code> if it is the main part of a chunk.
5482 <li><b><code>currentline</code>: </b>
5485 <code>currentline</code> is set to -1.
5488 <li><b><code>name</code>: </b>
5494 The <code>lua_getinfo</code> function checks how the function was
5497 then <code>name</code> is set to <code>NULL</code>.
5500 <li><b><code>namewhat</code>: </b>
5501 explains the <code>name</code> field.
5502 The value of <code>namewhat</code> can be
5503 <code>"global"</code>, <code>"local"</code>, <code>"method"</code>,
5504 <code>"field"</code>, <code>"upvalue"</code>, or <code>""</code> (the empty string),
5509 <li><b><code>istailcall</code>: </b>
5514 <li><b><code>nups</code>: </b>
5518 <li><b><code>nparams</code>: </b>
5523 <li><b><code>isvararg</code>: </b>
5533 <hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
5544 <hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
5555 <hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
5566 <hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
5576 the parameter <code>ar</code> must be a valid activation record that was
5577 filled by a previous call to <a href="#lua_getstack"><code>lua_getstack</code></a> or
5578 given as argument to a hook (see <a href="#lua_Hook"><code>lua_Hook</code></a>).
5583 and start the <code>what</code> string with the character '<code>&gt;</code>'.
5585 <code>lua_getinfo</code> pops the function from the top of the stack.)
5586 For instance, to know in which line a function <code>f</code> was defined,
5587 you can write the following code:
5597 Each character in the string <code>what</code>
5598 selects some fields of the structure <code>ar</code> to be filled or
5603 <li><b>'<code>n</code>': </b> fills in the field <code>name</code> and <code>namewhat</code>;
5606 <li><b>'<code>S</code>': </b>
5607 fills in the fields <code>source</code>, <code>short_src</code>,
5608 <code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;
5611 <li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>;
5614 <li><b>'<code>t</code>': </b> fills in the field <code>istailcall</code>;
5617 <li><b>'<code>u</code>': </b> fills in the fields
5618 <code>nups</code>, <code>nparams</code>, and <code>isvararg</code>;
5621 <li><b>'<code>f</code>': </b>
5626 <li><b>'<code>L</code>': </b>
5629 (A <em>valid line</em> is a line with some associated code,
5635 If this option is given together with option '<code>f</code>',
5643 (for instance, an invalid option in <code>what</code>).
5649 <hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
5660 the parameter <code>ar</code> must be a valid activation record that was
5661 filled by a previous call to <a href="#lua_getstack"><code>lua_getstack</code></a> or
5662 given as argument to a hook (see <a href="#lua_Hook"><code>lua_Hook</code></a>).
5663 The index <code>n</code> selects which local variable to inspect;
5664 see <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for details about variable indices
5669 <a href="#lua_getlocal"><code>lua_getlocal</code></a> pushes the variable's value onto the stack
5674 In the second case, <code>ar</code> must be <code>NULL</code> and the function
5682 Returns <code>NULL</code> (and pushes nothing)
5690 <hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
5699 This function fills parts of a <a href="#lua_Debug"><code>lua_Debug</code></a> structure with
5705 When there are no errors, <a href="#lua_getstack"><code>lua_getstack</code></a> returns 1;
5713 <hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
5718 Gets information about the <code>n</code>-th upvalue
5719 of the closure at index <code>funcindex</code>.
5722 Returns <code>NULL</code> (and pushes nothing)
5723 when the index <code>n</code> is greater than the number of upvalues.
5727 For C&nbsp;functions, this function uses the empty string <code>""</code>
5743 <hr><h3><a name="lua_Hook"><code>lua_Hook</code></a></h3>
5751 Whenever a hook is called, its <code>ar</code> argument has its field
5752 <code>event</code> set to the specific event that triggered the hook.
5754 <a name="pdf-LUA_HOOKCALL"><code>LUA_HOOKCALL</code></a>, <a name="pdf-LUA_HOOKRET"><code>LUA_HOOKR…
5755 <a name="pdf-LUA_HOOKTAILCALL"><code>LUA_HOOKTAILCALL</code></a>, <a name="pdf-LUA_HOOKLINE"><code>…
5756 and <a name="pdf-LUA_HOOKCOUNT"><code>LUA_HOOKCOUNT</code></a>.
5757 Moreover, for line events, the field <code>currentline</code> is also set.
5758 To get the value of any other field in <code>ar</code>,
5759 the hook must call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
5763 For call events, <code>event</code> can be <code>LUA_HOOKCALL</code>,
5764 the normal value, or <code>LUA_HOOKTAILCALL</code>, for a tail call;
5776 that is, they cannot call <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
5777 …a href="#lua_pcallk"><code>lua_pcallk</code></a>, or <a href="#lua_callk"><code>lua_callk</code></…
5784 calling <a href="#lua_yield"><code>lua_yield</code></a> with <code>nresults</code> equal to zero
5791 <hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
5800 Argument <code>f</code> is the hook function.
5801 <code>mask</code> specifies on which events the hook will be called:
5803 <a name="pdf-LUA_MASKCALL"><code>LUA_MASKCALL</code></a>,
5804 <a name="pdf-LUA_MASKRET"><code>LUA_MASKRET</code></a>,
5805 <a name="pdf-LUA_MASKLINE"><code>LUA_MASKLINE</code></a>,
5806 and <a name="pdf-LUA_MASKCOUNT"><code>LUA_MASKCOUNT</code></a>.
5807 The <code>count</code> argument is only meaningful when the mask
5808 includes <code>LUA_MASKCOUNT</code>.
5825 start the execution of a new line of code,
5826 or when it jumps back in the code (even to the same line).
5831 <code>count</code> instructions.
5838 A hook is disabled by setting <code>mask</code> to zero.
5844 <hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
5856 Returns <code>NULL</code> (and pops nothing)
5862 Parameters <code>ar</code> and <code>n</code> are as in function <a href="#lua_getlocal"><code>lua_…
5868 <hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
5880 Returns <code>NULL</code> (and pops nothing)
5881 when the index <code>n</code> is greater than the number of upvalues.
5885 Parameters <code>funcindex</code> and <code>n</code> are as in function <a href="#lua_getupvalue"><
5891 <hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p>
5896 Returns a unique identifier for the upvalue numbered <code>n</code>
5897 from the closure at index <code>funcindex</code>.
5909 Parameters <code>funcindex</code> and <code>n</code> are as in function <a href="#lua_getupvalue"><
5910 but <code>n</code> cannot be greater than the number of upvalues.
5916 <hr><h3><a name="lua_upvaluejoin"><code>lua_upvaluejoin</code></a></h3><p>
5922 Make the <code>n1</code>-th upvalue of the Lua closure at index <code>funcindex1</code>
5923 refer to the <code>n2</code>-th upvalue of the Lua closure at index <code>funcindex2</code>.
5945 are defined in header file <code>lauxlib.h</code> and
5946 have a prefix <code>luaL_</code>.
5954 more consistency to your code.
5969 (e.g., "<code>bad argument #1</code>"),
5974 Functions called <code>luaL_check*</code>
5987 <hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
5992 Adds the byte <code>c</code> to the buffer <code>B</code>
5993 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
5999 <hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
6004 Adds the string pointed to by <code>s</code> with length <code>l</code> to
6005 the buffer <code>B</code>
6006 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6013 <hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
6018 Adds to the buffer <code>B</code> (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>)
6019 a string of length <code>n</code> previously copied to the
6020 buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>).
6026 <hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
6031 Adds the zero-terminated string pointed to by <code>s</code>
6032 to the buffer <code>B</code>
6033 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6039 <hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
6045 to the buffer <code>B</code>
6046 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6059 <hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
6067 Checks whether <code>cond</code> is true.
6068 …ses an error with a standard message (see <a href="#luaL_argerror"><code>luaL_argerror</code></a>).
6074 <hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
6079 Raises an error reporting a problem with argument <code>arg</code>
6082 that includes <code>extramsg</code> as a comment:
6093 <hr><h3><a name="luaL_Buffer"><code>luaL_Buffer</code></a></h3>
6101 A string buffer allows C&nbsp;code to build Lua strings piecemeal.
6106 <li>First declare a variable <code>b</code> of type <a href="#luaL_Buffer"><code>luaL_Buffer</code>…
6108 <li>Then initialize it with a call <code>luaL_buffinit(L, &amp;b)</code>.</li>
6112 the <code>luaL_add*</code> functions.
6116 Finish by calling <code>luaL_pushresult(&amp;b)</code>.
6128 <li>First declare a variable <code>b</code> of type <a href="#luaL_Buffer"><code>luaL_Buffer</code>…
6131 size <code>sz</code> with a call <code>luaL_buffinitsize(L, &amp;b, sz)</code>.</li>
6136 Finish by calling <code>luaL_pushresultsize(&amp;b, sz)</code>,
6137 where <code>sz</code> is the total size of the resulting string
6154 (The only exception to this rule is <a href="#luaL_addvalue"><code>luaL_addvalue</code></a>.)
6155 After calling <a href="#luaL_pushresult"><code>luaL_pushresult</code></a> the stack is back to its
6163 <hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
6168 Initializes a buffer <code>B</code>.
6171 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6177 <hr><h3><a name="luaL_buffinitsize"><code>luaL_buffinitsize</code></a></h3><p>
6183 <a href="#luaL_buffinit"><code>luaL_buffinit</code></a>, <a href="#luaL_prepbuffsize"><code>luaL_pr…
6189 <hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
6198 If the object at index <code>obj</code> has a metatable and this
6199 metatable has a field <code>e</code>,
6210 <hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
6216 of any type (including <b>nil</b>) at position <code>arg</code>.
6222 <hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
6227 Checks whether the function argument <code>arg</code> is an integer
6229 and returns this integer cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.
6235 <hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
6240 Checks whether the function argument <code>arg</code> is a string
6242 if <code>l</code> is not <code>NULL</code> fills <code>*l</code>
6247 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
6254 <hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
6259 Checks whether the function argument <code>arg</code> is a number
6266 <hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
6274 Checks whether the function argument <code>arg</code> is a string and
6275 searches for this string in the array <code>lst</code>
6283 If <code>def</code> is not <code>NULL</code>,
6284 the function uses <code>def</code> as a default value when
6285 there is no argument <code>arg</code> or when this argument is <b>nil</b>.
6297 <hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
6302 Grows the stack size to <code>top + sz</code> elements,
6304 <code>msg</code> is an additional text to go into the error message
6305 (or <code>NULL</code> for no additional text).
6311 <hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
6316 Checks whether the function argument <code>arg</code> is a string
6321 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
6328 <hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
6333 Checks whether the function argument <code>arg</code> has type <code>t</code>.
6334 See <a href="#lua_type"><code>lua_type</code></a> for the encoding of types for <code>t</code>.
6340 <hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
6345 Checks whether the function argument <code>arg</code> is a userdata
6346 of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>…
6347 returns the userdata address (see <a href="#lua_touserdata"><code>lua_touserdata</code></a>).
6353 <hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p>
6360 and the code making the call are all using the same version of Lua.
6369 <hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
6387 <hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
6405 <hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
6411 The error message format is given by <code>fmt</code>
6413 following the same rules of <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>.
6422 as <code>return luaL_error(<em>args</em>)</code>.
6428 <hr><h3><a name="luaL_execresult"><code>luaL_execresult</code></a></h3><p>
6435 (<a href="#pdf-os.execute"><code>os.execute</code></a> and <a href="#pdf-io.close"><code>io.close</
6441 <hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>
6448 …pdf-io.open"><code>io.open</code></a>, <a href="#pdf-os.rename"><code>os.rename</code></a>, <a hre…
6454 <hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
6459 Pushes onto the stack the field <code>e</code> from the metatable
6460 of the object at index <code>obj</code> and returns the type of the pushed value.
6463 pushes nothing and returns <code>LUA_TNIL</code>.
6469 <hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
6474 Pushes onto the stack the metatable associated with name <code>tname</code>
6475 in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>)
6483 <hr><h3><a name="luaL_getsubtable"><code>luaL_getsubtable</code></a></h3><p>
6488 Ensures that the value <code>t[fname]</code>,
6489 where <code>t</code> is the value at index <code>idx</code>,
6499 <hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
6507 Creates a copy of string <code>s</code> by replacing
6508 any occurrence of the string <code>p</code>
6509 with the string <code>r</code>.
6516 <hr><h3><a name="luaL_len"><code>luaL_len</code></a></h3><p>
6523 it is equivalent to the '<code>#</code>' operator in Lua (see <a href="#3.4.7">&sect;3.4.7</a>).
6531 <hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
6539 …ent to <a href="#luaL_loadbufferx"><code>luaL_loadbufferx</code></a> with <code>mode</code> equal …
6545 <hr><h3><a name="luaL_loadbufferx"><code>luaL_loadbufferx</code></a></h3><p>
6555 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the
6556 buffer pointed to by <code>buff</code> with size <code>sz</code>.
6560 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
6561 <code>name</code> is the chunk name,
6563 The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>.
6569 <hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
6574 …valent to <a href="#luaL_loadfilex"><code>luaL_loadfilex</code></a> with <code>mode</code> equal t…
6580 <hr><h3><a name="luaL_loadfilex"><code>luaL_loadfilex</code></a></h3><p>
6587 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the file
6588 named <code>filename</code>.
6589 If <code>filename</code> is <code>NULL</code>,
6591 The first line in the file is ignored if it starts with a <code>#</code>.
6595 The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>.
6599 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>,
6600 but it has an extra error code <a name="pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a>
6606 As <a href="#lua_load"><code>lua_load</code></a>, this function only loads the chunk;
6613 <hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
6619 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in
6620 the zero-terminated string <code>s</code>.
6624 This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
6628 Also as <a href="#lua_load"><code>lua_load</code></a>, this function only loads the chunk;
6635 <hr><h3><a name="luaL_newlib"><code>luaL_newlib</code></a></h3><p>
6641 the functions in list <code>l</code>.
6650 The array <code>l</code> must be the actual array,
6657 <hr><h3><a name="luaL_newlibtable"><code>luaL_newlibtable</code></a></h3><p>
6663 to store all entries in the array <code>l</code>
6665 It is intended to be used in conjunction with <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></…
6666 (see <a href="#luaL_newlib"><code>luaL_newlib</code></a>).
6671 The array <code>l</code> must be the actual array,
6678 <hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
6683 If the registry already has the key <code>tname</code>,
6687 adds to this new table the pair <code>__name = tname</code>,
6688 adds to the registry the pair <code>[tname] = new table</code>,
6690 (The entry <code>__name</code> is used by some error-reporting functions.)
6695 with <code>tname</code> in the registry.
6701 <hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
6707 It calls <a href="#lua_newstate"><code>lua_newstate</code></a> with an
6708 allocator based on the standard&nbsp;C <code>realloc</code> function
6716 or <code>NULL</code> if there is a memory allocation error.
6722 <hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
6733 <hr><h3><a name="luaL_opt"><code>luaL_opt</code></a></h3><p>
6743 In words, if the argument <code>arg</code> is nil or absent,
6744 the macro results in the default <code>dflt</code>.
6745 Otherwise, it results in the result of calling <code>func</code>
6746 with the state <code>L</code> and the argument index <code>arg</code> as
6748 Note that it evaluates the expression <code>dflt</code> only if needed.
6754 <hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
6761 If the function argument <code>arg</code> is an integer
6765 returns <code>d</code>.
6772 <hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
6780 If the function argument <code>arg</code> is a string,
6783 returns <code>d</code>.
6788 If <code>l</code> is not <code>NULL</code>,
6789 fills the position <code>*l</code> with the result's length.
6790 If the result is <code>NULL</code>
6791 (only possible when returning <code>d</code> and <code>d == NULL</code>),
6796 This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
6803 <hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
6808 If the function argument <code>arg</code> is a number,
6811 returns <code>d</code>.
6818 <hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
6825 If the function argument <code>arg</code> is a string,
6828 returns <code>d</code>.
6835 <hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
6840 Equivalent to <a href="#luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a>
6841 with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
6847 <hr><h3><a name="luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a></h3><p>
6852 Returns an address to a space of size <code>sz</code>
6853 where you can copy a string to be added to buffer <code>B</code>
6854 (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
6856 <a href="#luaL_addsize"><code>luaL_addsize</code></a> with the size of the string to actually add
6863 <hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
6868 Finishes the use of buffer <code>B</code> leaving the final string on
6875 <hr><h3><a name="luaL_pushresultsize"><code>luaL_pushresultsize</code></a></h3><p>
6880 …sequence <a href="#luaL_addsize"><code>luaL_addsize</code></a>, <a href="#luaL_pushresult"><code>l…
6886 <hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
6892 in the table at index <code>t</code>,
6898 As long as you do not manually add integer keys into table <code>t</code>,
6899 <a href="#luaL_ref"><code>luaL_ref</code></a> ensures the uniqueness of the key it returns.
6900 You can retrieve an object referred by reference <code>r</code>
6901 by calling <code>lua_rawgeti(L, t, r)</code>.
6902 Function <a href="#luaL_unref"><code>luaL_unref</code></a> frees a reference and its associated obj…
6907 <a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <a name="pdf-LUA_REFNIL"><code>L…
6908 The constant <a name="pdf-LUA_NOREF"><code>LUA_NOREF</code></a> is guaranteed to be different
6909 from any reference returned by <a href="#luaL_ref"><code>luaL_ref</code></a>.
6915 <hr><h3><a name="luaL_Reg"><code>luaL_Reg</code></a></h3>
6923 <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a>.
6924 <code>name</code> is the function name and <code>func</code> is a pointer to
6926 Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with a sentinel entry
6927 in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
6933 <hr><h3><a name="luaL_requiref"><code>luaL_requiref</code></a></h3><p>
6939 If <code>modname</code> is not already present in <a href="#pdf-package.loaded"><code>package.loade…
6940 calls function <code>openf</code> with string <code>modname</code> as an argument
6941 and sets the call result in <code>package.loaded[modname]</code>,
6942 as if that function has been called through <a href="#pdf-require"><code>require</code></a>.
6946 If <code>glb</code> is true,
6947 also stores the module into global <code>modname</code>.
6957 <hr><h3><a name="luaL_setfuncs"><code>luaL_setfuncs</code></a></h3><p>
6962 Registers all functions in the array <code>l</code>
6963 (see <a href="#luaL_Reg"><code>luaL_Reg</code></a>) into the table on the top of the stack
6968 When <code>nup</code> is not zero,
6969 all functions are created sharing <code>nup</code> upvalues,
6978 <hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
6984 as the metatable associated with name <code>tname</code>
6985 in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
6991 <hr><h3><a name="luaL_Stream"><code>luaL_Stream</code></a></h3>
7004 with a metatable called <code>LUA_FILEHANDLE</code>
7005 (where <code>LUA_FILEHANDLE</code> is a macro with the actual metatable's name).
7007 (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
7011 This userdata must start with the structure <code>luaL_Stream</code>;
7013 Field <code>f</code> points to the corresponding C stream
7014 (or it can be <code>NULL</code> to indicate an incompletely created handle).
7015 Field <code>closef</code> points to a Lua function
7022 it changes the field value to <code>NULL</code>
7029 <hr><h3><a name="luaL_testudata"><code>luaL_testudata</code></a></h3><p>
7034 This function works like <a href="#luaL_checkudata"><code>luaL_checkudata</code></a>,
7036 it returns <code>NULL</code> instead of raising an error.
7042 <hr><h3><a name="luaL_tolstring"><code>luaL_tolstring</code></a></h3><p>
7051 If <code>len</code> is not <code>NULL</code>,
7052 the function also sets <code>*len</code> with the string length.
7056 If the value has a metatable with a <code>__tostring</code> field,
7057 then <code>luaL_tolstring</code> calls the corresponding metamethod
7065 <hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p>
7071 Creates and pushes a traceback of the stack <code>L1</code>.
7072 If <code>msg</code> is not <code>NULL</code> it is appended
7074 The <code>level</code> parameter tells at which level
7081 <hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
7092 <hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
7097 Releases reference <code>ref</code> from the table at index <code>t</code>
7098 (see <a href="#luaL_ref"><code>luaL_ref</code></a>).
7101 The reference <code>ref</code> is also freed to be used again.
7105 If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a href="#pdf-LUA_REF…
7106 <a href="#luaL_unref"><code>luaL_unref</code></a> does nothing.
7112 <hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
7118 of the control at level <code>lvl</code> in the call stack.
7144 (e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable…
7148 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
7186 the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> fun…
7190 <a href="#luaL_requiref"><code>luaL_requiref</code></a> to call
7191 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
7192 <a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
7193 <a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),
7194 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
7195 <a name="pdf-luaopen_utf8"><code>luaopen_utf8</code></a> (for the UTF8 library),
7196 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
7197 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
7198 <a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
7199 <a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the operating system library),
7200 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
7201 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
7215 <hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
7219 Calls <a href="#pdf-error"><code>error</code></a> if
7220 the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
7223 <code>message</code> is the error object;
7224 when absent, it defaults to "<code>assertion failed!</code>"
7230 <hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>
7235 It performs different functions according to its first argument, <code>opt</code>:
7239 <li><b>"<code>collect</code>": </b>
7244 <li><b>"<code>stop</code>": </b>
7250 <li><b>"<code>restart</code>": </b>
7254 <li><b>"<code>count</code>": </b>
7262 <li><b>"<code>step</code>": </b>
7264 The step "size" is controlled by <code>arg</code>.
7273 <li><b>"<code>setpause</code>": </b>
7274 sets <code>arg</code> as the new value for the <em>pause</em> of
7279 <li><b>"<code>setstepmul</code>": </b>
7280 sets <code>arg</code> as the new value for the <em>step multiplier</em> of
7285 <li><b>"<code>isrunning</code>": </b>
7295 <hr><h3><a name="pdf-dofile"><code>dofile ([filename])</code></a></h3>
7298 <code>dofile</code> executes the contents of the standard input (<code>stdin</code>).
7300 In case of errors, <code>dofile</code> propagates the error
7301 to its caller (that is, <code>dofile</code> does not run in protected mode).
7307 <hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
7309 and returns <code>message</code> as the error object.
7310 Function <code>error</code> never returns.
7314 Usually, <code>error</code> adds some information about the error position
7316 The <code>level</code> argument specifies how to get the error position.
7318 <code>error</code> function was called.
7320 that called <code>error</code> was called; and so on.
7328 <hr><h3><a name="pdf-_G"><code>_G</code></a></h3>
7339 <hr><h3><a name="pdf-getmetatable"><code>getmetatable (object)</code></a></h3>
7343 If <code>object</code> does not have a metatable, returns <b>nil</b>.
7345 if the object's metatable has a <code>__metatable</code> field,
7353 <hr><h3><a name="pdf-ipairs"><code>ipairs (t)</code></a></h3>
7357 Returns three values (an iterator function, the table <code>t</code>, and 0)
7364 (<code>1,t[1]</code>), (<code>2,t[2]</code>), ...,
7371 <hr><h3><a name="pdf-load"><code>load (chunk [, chunkname [, mode [, env]]])</code></a></h3>
7379 If <code>chunk</code> is a string, the chunk is this string.
7380 If <code>chunk</code> is a function,
7381 <code>load</code> calls it repeatedly to get the chunk pieces.
7382 Each call to <code>chunk</code> must return a string that concatenates
7395 the first upvalue is set to the value of <code>env</code>,
7401 the <code>_ENV</code> variable (see <a href="#2.2">&sect;2.2</a>).
7403 …binary chunk created from a function (see <a href="#pdf-string.dump"><code>string.dump</code></a>),
7410 <code>chunkname</code> is used as the name of the chunk for error messages
7413 it defaults to <code>chunk</code>, if <code>chunk</code> is a string,
7414 or to "<code>=(load)</code>" otherwise.
7418 The string <code>mode</code> controls whether the chunk can be text or binary
7420 It may be the string "<code>b</code>" (only binary chunks),
7421 "<code>t</code>" (only text chunks),
7422 or "<code>bt</code>" (both binary and text).
7423 The default is "<code>bt</code>".
7435 <hr><h3><a name="pdf-loadfile"><code>loadfile ([filename [, mode [, env]]])</code></a></h3>
7439 Similar to <a href="#pdf-load"><code>load</code></a>,
7440 but gets the chunk from file <code>filename</code>
7448 <hr><h3><a name="pdf-next"><code>next (table [, index])</code></a></h3>
7455 <code>next</code> returns the next index of the table
7458 <code>next</code> returns an initial index
7462 <code>next</code> returns <b>nil</b>.
7465 you can use <code>next(t)</code> to check whether a table is empty.
7476 The behavior of <code>next</code> is undefined if,
7486 <hr><h3><a name="pdf-pairs"><code>pairs (t)</code></a></h3>
7490 If <code>t</code> has a metamethod <code>__pairs</code>,
7491 calls it with <code>t</code> as argument and returns the first three
7497 returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</co…
7503 will iterate over all key&ndash;value pairs of table <code>t</code>.
7507 See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
7514 <hr><h3><a name="pdf-pcall"><code>pcall (f [, arg1, &middot;&middot;&middot;])</code></a></h3>
7518 Calls function <code>f</code> with
7520 This means that any error inside&nbsp;<code>f</code> is not propagated;
7521 instead, <code>pcall</code> catches the error
7522 and returns a status code.
7523 Its first result is the status code (a boolean),
7525 In such case, <code>pcall</code> also returns all results from the call,
7527 In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.
7533 <hr><h3><a name="pdf-print"><code>print (&middot;&middot;&middot;)</code></a></h3>
7535 and prints their values to <code>stdout</code>,
7536 using the <a href="#pdf-tostring"><code>tostring</code></a> function to convert each argument to a …
7537 <code>print</code> is not intended for formatted output,
7541 use <a href="#pdf-string.format"><code>string.format</code></a> and <a href="#pdf-io.write"><code>i…
7547 <hr><h3><a name="pdf-rawequal"><code>rawequal (v1, v2)</code></a></h3>
7548 Checks whether <code>v1</code> is equal to <code>v2</code>,
7549 without invoking the <code>__eq</code> metamethod.
7556 <hr><h3><a name="pdf-rawget"><code>rawget (table, index)</code></a></h3>
7557 Gets the real value of <code>table[index]</code>,
7558 without invoking the <code>__index</code> metamethod.
7559 <code>table</code> must be a table;
7560 <code>index</code> may be any value.
7566 <hr><h3><a name="pdf-rawlen"><code>rawlen (v)</code></a></h3>
7567 Returns the length of the object <code>v</code>,
7569 without invoking the <code>__len</code> metamethod.
7576 <hr><h3><a name="pdf-rawset"><code>rawset (table, index, value)</code></a></h3>
7577 Sets the real value of <code>table[index]</code> to <code>value</code>,
7578 without invoking the <code>__newindex</code> metamethod.
7579 <code>table</code> must be a table,
7580 <code>index</code> any value different from <b>nil</b> and NaN,
7581 and <code>value</code> any Lua value.
7585 This function returns <code>table</code>.
7591 <hr><h3><a name="pdf-select"><code>select (index, &middot;&middot;&middot;)</code></a></h3>
7595 If <code>index</code> is a number,
7596 returns all arguments after argument number <code>index</code>;
7598 Otherwise, <code>index</code> must be the string <code>"#"</code>,
7599 and <code>select</code> returns the total number of extra arguments it received.
7605 <hr><h3><a name="pdf-setmetatable"><code>setmetatable (table, metatable)</code></a></h3>
7610 (To change the metatable of other types from Lua code,
7612 If <code>metatable</code> is <b>nil</b>,
7614 If the original metatable has a <code>__metatable</code> field,
7619 This function returns <code>table</code>.
7625 <hr><h3><a name="pdf-tonumber"><code>tonumber (e [, base])</code></a></h3>
7629 When called with no <code>base</code>,
7630 <code>tonumber</code> tries to convert its argument to a number.
7633 then <code>tonumber</code> returns this number;
7644 When called with <code>base</code>,
7645 then <code>e</code> must be a string to be interpreted as
7648 In bases above&nbsp;10, the letter '<code>A</code>' (in either upper or lower case)
7649 represents&nbsp;10, '<code>B</code>' represents&nbsp;11, and so forth,
7650 with '<code>Z</code>' representing 35.
7651 If the string <code>e</code> is not a valid numeral in the given base,
7658 <hr><h3><a name="pdf-tostring"><code>tostring (v)</code></a></h3>
7662 use <a href="#pdf-string.format"><code>string.format</code></a>.)
7666 If the metatable of <code>v</code> has a <code>__tostring</code> field,
7667 then <code>tostring</code> calls the corresponding value
7668 with <code>v</code> as argument,
7675 <hr><h3><a name="pdf-type"><code>type (v)</code></a></h3>
7678 "<code>nil</code>" (a string, not the value <b>nil</b>),
7679 "<code>number</code>",
7680 "<code>string</code>",
7681 "<code>boolean</code>",
7682 "<code>table</code>",
7683 "<code>function</code>",
7684 "<code>thread</code>",
7685 and "<code>userdata</code>".
7691 <hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
7697 The current value of this variable is "<code>Lua 5.3</code>".
7703 <hr><h3><a name="pdf-xpcall"><code>xpcall (f, msgh [, arg1, &middot;&middot;&middot;])</code></a></…
7707 This function is similar to <a href="#pdf-pcall"><code>pcall</code></a>,
7708 except that it sets a new message handler <code>msgh</code>.
7720 which come inside the table <a name="pdf-coroutine"><code>coroutine</code></a>.
7725 <hr><h3><a name="pdf-coroutine.create"><code>coroutine.create (f)</code></a></h3>
7729 Creates a new coroutine, with body <code>f</code>.
7730 <code>f</code> must be a function.
7732 an object with type <code>"thread"</code>.
7738 <hr><h3><a name="pdf-coroutine.isyieldable"><code>coroutine.isyieldable ()</code></a></h3>
7753 <hr><h3><a name="pdf-coroutine.resume"><code>coroutine.resume (co [, val1, &middot;&middot;&middot;…
7757 Starts or continues the execution of coroutine <code>co</code>.
7760 The values <code>val1</code>, ... are passed
7763 <code>resume</code> restarts it;
7764 the values <code>val1</code>, ... are passed
7770 <code>resume</code> returns <b>true</b> plus any values passed to <code>yield</code>
7774 <code>resume</code> returns <b>false</b> plus the error message.
7780 <hr><h3><a name="pdf-coroutine.running"><code>coroutine.running ()</code></a></h3>
7791 <hr><h3><a name="pdf-coroutine.status"><code>coroutine.status (co)</code></a></h3>
7795 Returns the status of coroutine <code>co</code>, as a string:
7796 <code>"running"</code>,
7797 if the coroutine is running (that is, it called <code>status</code>);
7798 <code>"suspended"</code>, if the coroutine is suspended in a call to <code>yield</code>,
7800 <code>"normal"</code> if the coroutine is active but not running
7802 and <code>"dead"</code> if the coroutine has finished its body function,
7809 <hr><h3><a name="pdf-coroutine.wrap"><code>coroutine.wrap (f)</code></a></h3>
7813 Creates a new coroutine, with body <code>f</code>.
7814 <code>f</code> must be a function.
7817 extra arguments to <code>resume</code>.
7818 Returns the same values returned by <code>resume</code>,
7826 <hr><h3><a name="pdf-coroutine.yield"><code>coroutine.yield (&middot;&middot;&middot;)</code></a></…
7831 Any arguments to <code>yield</code> are passed as extra results to <code>resume</code>.
7845 <a href="#pdf-require"><code>require</code></a>.
7846 Everything else is exported in a table <a name="pdf-package"><code>package</code></a>.
7850 <hr><h3><a name="pdf-require"><code>require (modname)</code></a></h3>
7855 The function starts by looking into the <a href="#pdf-package.loaded"><code>package.loaded</code></…
7856 to determine whether <code>modname</code> is already loaded.
7857 If it is, then <code>require</code> returns the value stored
7858 at <code>package.loaded[modname]</code>.
7864 <code>require</code> is guided by the <a href="#pdf-package.searchers"><code>package.searchers</cod…
7866 we can change how <code>require</code> looks for a module.
7868 for <a href="#pdf-package.searchers"><code>package.searchers</code></a>.
7872 First <code>require</code> queries <code>package.preload[modname]</code>.
7875 Otherwise <code>require</code> searches for a Lua loader using the
7876 path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
7878 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
7880 …m>all-in-one</em> loader (see <a href="#pdf-package.searchers"><code>package.searchers</code></a>).
7885 <code>require</code> calls the loader with two arguments:
7886 <code>modname</code> and an extra value dependent on how it got the loader.
7890 <code>require</code> assigns the returned value to <code>package.loaded[modname]</code>.
7892 has not assigned any value to <code>package.loaded[modname]</code>,
7893 then <code>require</code> assigns <b>true</b> to this entry.
7894 In any case, <code>require</code> returns the
7895 final value of <code>package.loaded[modname]</code>.
7901 then <code>require</code> raises an error.
7907 <hr><h3><a name="pdf-package.config"><code>package.config</code></a></h3>
7917 Default is '<code>\</code>' for Windows and '<code>/</code>' for all other systems.</li>
7920 Default is '<code>;</code>'.</li>
7924 Default is '<code>?</code>'.</li>
7928 Default is '<code>!</code>'.</li>
7931 when building the <code>luaopen_</code> function name.
7932 Default is '<code>-</code>'.</li>
7939 <hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
7943 The path used by <a href="#pdf-require"><code>require</code></a> to search for a C&nbsp;loader.
7947 Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the …
7948 it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
7949 using the environment variable <a name="pdf-LUA_CPATH_5_3"><code>LUA_CPATH_5_3</code></a>,
7950 or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>,
7951 or a default path defined in <code>luaconf.h</code>.
7957 <hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
7961 A table used by <a href="#pdf-require"><code>require</code></a> to control which
7963 When you require a module <code>modname</code> and
7964 <code>package.loaded[modname]</code> is not false,
7965 <a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
7971 table used by <a href="#pdf-require"><code>require</code></a>.
7977 <hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
7981 Dynamically links the host program with the C&nbsp;library <code>libname</code>.
7985 If <code>funcname</code> is "<code>*</code>",
7990 it looks for a function <code>funcname</code> inside the library
7992 So, <code>funcname</code> must follow the <a href="#lua_CFunction"><code>lua_CFunction</code></a> p…
7993 (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
7999 Unlike <a href="#pdf-require"><code>require</code></a>,
8002 <code>libname</code> must be the complete file name of the C&nbsp;library,
8004 <code>funcname</code> must be the exact name exported by the C&nbsp;library
8012 plus other Unix systems that support the <code>dlfcn</code> standard).
8018 <hr><h3><a name="pdf-package.path"><code>package.path</code></a></h3>
8022 The path used by <a href="#pdf-require"><code>require</code></a> to search for a Lua loader.
8027 the value of the environment variable <a name="pdf-LUA_PATH_5_3"><code>LUA_PATH_5_3</code></a> or
8028 the environment variable <a name="pdf-LUA_PATH"><code>LUA_PATH</code></a> or
8029 with a default path defined in <code>luaconf.h</code>,
8031 Any "<code>;;</code>" in the value of the environment variable
8038 <hr><h3><a name="pdf-package.preload"><code>package.preload</code></a></h3>
8043 (see <a href="#pdf-require"><code>require</code></a>).
8049 table used by <a href="#pdf-require"><code>require</code></a>.
8055 <hr><h3><a name="pdf-package.searchers"><code>package.searchers</code></a></h3>
8059 A table used by <a href="#pdf-require"><code>require</code></a> to control how to load modules.
8065 <a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
8066 with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
8080 <a href="#pdf-package.preload"><code>package.preload</code></a> table.
8085 using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
8086 …one as described in function <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
8091 using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
8093 …one as described in function <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
8100 the searcher for module <code>foo</code>
8101 will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>,
8102 and <code>/usr/local/foo/init.so</code>, in that order.
8108 The name of this C&nbsp;function is the string "<code>luaopen_</code>"
8113 For instance, if the module name is <code>a.b.c-v2.1</code>,
8114 the function name will be <code>luaopen_a_b_c</code>.
8121 For instance, when requiring <code>a.b.c</code>,
8122 it will search for a C&nbsp;library for <code>a</code>.
8125 in our example, that would be <code>luaopen_a_b_c</code>.
8134 as returned by <a href="#pdf-package.searchpath"><code>package.searchpath</code></a>.
8141 <hr><h3><a name="pdf-package.searchpath"><code>package.searchpath (name, path [, sep [, rep]])</cod…
8145 Searches for the given <code>name</code> in the given <code>path</code>.
8153 in the template with a copy of <code>name</code>
8154 wherein all occurrences of <code>sep</code>
8156 were replaced by <code>rep</code>
8167 the search for the name <code>foo.a</code>
8169 <code>./foo/a.lua</code>, <code>./foo/a.lc</code>, and
8170 <code>/usr/local/foo/a/init.lua</code>, in that order.
8199 <a name="pdf-string"><code>string</code></a>.
8201 where the <code>__index</code> field points to the <code>string</code> table.
8203 For instance, <code>string.byte(s,i)</code>
8204 can be written as <code>s:byte(i)</code>.
8212 <hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
8213 Returns the internal numeric codes of the characters <code>s[i]</code>,
8214 <code>s[i+1]</code>, ..., <code>s[j]</code>.
8215 The default value for <code>i</code> is&nbsp;1;
8216 the default value for <code>j</code> is&nbsp;<code>i</code>.
8218 following the same rules of function <a href="#pdf-string.sub"><code>string.sub</code></a>.
8228 <hr><h3><a name="pdf-string.char"><code>string.char (&middot;&middot;&middot;)</code></a></h3>
8231 in which each character has the internal numeric code equal
8242 <hr><h3><a name="pdf-string.dump"><code>string.dump (function [, strip])</code></a></h3>
8249 so that a later <a href="#pdf-load"><code>load</code></a> on this string returns
8251 If <code>strip</code> is a true value,
8269 <hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
8274 <code>pattern</code> (see <a href="#6.4.1">&sect;6.4.1</a>) in the string <code>s</code>.
8275 If it finds a match, then <code>find</code> returns the indices of&nbsp;<code>s</code>
8278 A third, optional numeric argument <code>init</code> specifies
8281 A value of <b>true</b> as a fourth, optional argument <code>plain</code>
8284 with no characters in <code>pattern</code> being considered magic.
8285 Note that if <code>plain</code> is given, then <code>init</code> must be given as well.
8298 <hr><h3><a name="pdf-string.format"><code>string.format (formatstring, &middot;&middot;&middot;)</c…
8304 The format string follows the same rules as the ISO&nbsp;C function <code>sprintf</code>.
8306 <code>*</code>, <code>h</code>, <code>L</code>, <code>l</code>, <code>n</code>,
8307 and <code>p</code> are not supported
8308 and that there is an extra option, <code>q</code>.
8312 The <code>q</code> option formats a string between double quotes,
8329 <code>A</code>, <code>a</code>, <code>E</code>, <code>e</code>, <code>f</code>,
8330 <code>G</code>, and <code>g</code> all expect a number as argument.
8331 Options <code>c</code>, <code>d</code>,
8332 <code>i</code>, <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code>
8335 options <code>A</code> and <code>a</code> (hexadecimal floats)
8340 Option <code>s</code> expects a string;
8342 it is converted to one following the same rules of <a href="#pdf-tostring"><code>tostring</code></a…
8350 <hr><h3><a name="pdf-string.gmatch"><code>string.gmatch (s, pattern)</code></a></h3>
8353 returns the next captures from <code>pattern</code> (see <a href="#6.4.1">&sect;6.4.1</a>)
8354 over the string <code>s</code>.
8355 If <code>pattern</code> specifies no captures,
8361 will iterate over all the words from string <code>s</code>,
8370 The next example collects all pairs <code>key=value</code> from the
8382 For this function, a caret '<code>^</code>' at the start of a pattern does not
8389 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
8390 Returns a copy of <code>s</code>
8391 in which all (or the first <code>n</code>, if given)
8392 occurrences of the <code>pattern</code> (see <a href="#6.4.1">&sect;6.4.1</a>) have been
8393 replaced by a replacement string specified by <code>repl</code>,
8395 <code>gsub</code> also returns, as its second value,
8397 The name <code>gsub</code> comes from <em>Global SUBstitution</em>.
8401 If <code>repl</code> is a string, then its value is used for replacement.
8402 The character&nbsp;<code>%</code> works as an escape character:
8403 any sequence in <code>repl</code> of the form <code>%<em>d</em></code>,
8406 The sequence <code>%0</code> stands for the whole match.
8407 The sequence <code>%%</code> stands for a single&nbsp;<code>%</code>.
8411 If <code>repl</code> is a table, then the table is queried for every match,
8416 If <code>repl</code> is a function, then this function is called every time a
8465 <hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
8467 The empty string <code>""</code> has length 0.
8469 so <code>"a\000bc\000"</code> has length 5.
8475 <hr><h3><a name="pdf-string.lower"><code>string.lower (s)</code></a></h3>
8485 <hr><h3><a name="pdf-string.match"><code>string.match (s, pattern [, init])</code></a></h3>
8487 <code>pattern</code> (see <a href="#6.4.1">&sect;6.4.1</a>) in the string <code>s</code>.
8488 If it finds one, then <code>match</code> returns
8491 If <code>pattern</code> specifies no captures,
8493 A third, optional numeric argument <code>init</code> specifies
8501 <hr><h3><a name="pdf-string.pack"><code>string.pack (fmt, v1, v2, &middot;&middot;&middot;)</code><…
8505 Returns a binary string containing the values <code>v1</code>, <code>v2</code>, etc.
8507 according to the format string <code>fmt</code> (see <a href="#6.4.2">&sect;6.4.2</a>).
8513 <hr><h3><a name="pdf-string.packsize"><code>string.packsize (fmt)</code></a></h3>
8517 Returns the size of a string resulting from <a href="#pdf-string.pack"><code>string.pack</code></a>
8520 '<code>s</code>' or '<code>z</code>' (see <a href="#6.4.2">&sect;6.4.2</a>).
8526 <hr><h3><a name="pdf-string.rep"><code>string.rep (s, n [, sep])</code></a></h3>
8527 Returns a string that is the concatenation of <code>n</code> copies of
8528 the string <code>s</code> separated by the string <code>sep</code>.
8529 The default value for <code>sep</code> is the empty string
8531 Returns the empty string if <code>n</code> is not positive.
8542 <hr><h3><a name="pdf-string.reverse"><code>string.reverse (s)</code></a></h3>
8543 Returns a string that is the string <code>s</code> reversed.
8549 <hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
8550 Returns the substring of <code>s</code> that
8551 starts at <code>i</code> and continues until <code>j</code>;
8552 <code>i</code> and <code>j</code> can be negative.
8553 If <code>j</code> is absent, then it is assumed to be equal to -1
8556 the call <code>string.sub(s,1,j)</code> returns a prefix of <code>s</code>
8557 with length <code>j</code>,
8558 and <code>string.sub(s, -i)</code> (for a positive <code>i</code>)
8559 returns a suffix of <code>s</code>
8560 with length <code>i</code>.
8565 <code>i</code> is less than 1,
8567 If <code>j</code> is greater than the string length,
8570 <code>i</code> is greater than <code>j</code>,
8577 <hr><h3><a name="pdf-string.unpack"><code>string.unpack (fmt, s [, pos])</code></a></h3>
8581 Returns the values packed in string <code>s</code> (see <a href="#pdf-string.pack"><code>string.pac…
8582 according to the format string <code>fmt</code> (see <a href="#6.4.2">&sect;6.4.2</a>).
8583 An optional <code>pos</code> marks where
8584 to start reading in <code>s</code> (default is 1).
8586 this function also returns the index of the first unread byte in <code>s</code>.
8592 <hr><h3><a name="pdf-string.upper"><code>string.upper (s)</code></a></h3>
8607 <a href="#pdf-string.find"><code>string.find</code></a>,
8608 <a href="#pdf-string.gmatch"><code>string.gmatch</code></a>,
8609 <a href="#pdf-string.gsub"><code>string.gsub</code></a>,
8610 and <a href="#pdf-string.match"><code>string.match</code></a>.
8624 <code>^$()%.[]*+-?</code>)
8628 <li><b><code>.</code>: </b> (a dot) represents all characters.</li>
8630 <li><b><code>%a</code>: </b> represents all letters.</li>
8632 <li><b><code>%c</code>: </b> represents all control characters.</li>
8634 <li><b><code>%d</code>: </b> represents all digits.</li>
8636 <li><b><code>%g</code>: </b> represents all printable characters except space.</li>
8638 <li><b><code>%l</code>: </b> represents all lowercase letters.</li>
8640 <li><b><code>%p</code>: </b> represents all punctuation characters.</li>
8642 <li><b><code>%s</code>: </b> represents all space characters.</li>
8644 <li><b><code>%u</code>: </b> represents all uppercase letters.</li>
8646 <li><b><code>%w</code>: </b> represents all alphanumeric characters.</li>
8648 <li><b><code>%x</code>: </b> represents all hexadecimal digits.</li>
8650 <li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character)
8655 can be preceded by a '<code>%</code>'
8659 <li><b><code>[<em>set</em>]</code>: </b>
8664 in ascending order, with a '<code>-</code>'.
8665 All classes <code>%</code><em>x</em> described above can also be used as
8668 For example, <code>[%w_]</code> (or <code>[_%w]</code>)
8670 <code>[0-7]</code> represents the octal digits,
8671 and <code>[0-7%l%-]</code> represents the octal digits plus
8672 the lowercase letters plus the '<code>-</code>' character.
8685 Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code>
8689 <li><b><code>[^<em>set</em>]</code>: </b>
8695 For all classes represented by single letters (<code>%a</code>, <code>%c</code>, etc.),
8697 For instance, <code>%S</code> represents all non-space characters.
8703 In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.
8720 a single character class followed by '<code>*</code>',
8726 a single character class followed by '<code>+</code>',
8732 a single character class followed by '<code>-</code>',
8734 Unlike '<code>*</code>',
8739 a single character class followed by '<code>?</code>',
8745 <code>%<em>n</em></code>, for <em>n</em> between 1 and 9;
8751 <code>%b<em>xy</em></code>, where <em>x</em> and <em>y</em> are two distinct characters;
8757 For instance, the item <code>%b()</code> matches expressions with
8762 <code>%f[<em>set</em>]</code>, a <em>frontier pattern</em>;
8768 they were the character '<code>\0</code>'.
8778 A caret '<code>^</code>' at the beginning of a pattern anchors the match at the
8780 A '<code>$</code>' at the end of a pattern anchors the match at the
8783 '<code>^</code>' and '<code>$</code>' have no special meaning and represent themselves.
8795 For instance, in the pattern <code>"(a*(.)%w(%s*))"</code>,
8796 the part of the string matching <code>"a*(.)%w(%s*)"</code> is
8798 the character matching "<code>.</code>" is captured with number&nbsp;2,
8799 and the part matching "<code>%s*</code>" has number&nbsp;3.
8803 As a special case, the empty capture <code>()</code> captures
8805 For instance, if we apply the pattern <code>"()aa()"</code> on the
8806 string <code>"flaaap"</code>, there will be two captures: 3&nbsp;and&nbsp;5.
8817 The first argument to <a href="#pdf-string.pack"><code>string.pack</code></a>,
8818 …a href="#pdf-string.packsize"><code>string.packsize</code></a>, and <a href="#pdf-string.unpack"><
8828 <li><b><code>&lt;</code>: </b>sets little endian</li>
8829 <li><b><code>&gt;</code>: </b>sets big endian</li>
8830 <li><b><code>=</code>: </b>sets native endian</li>
8831 <li><b><code>![<em>n</em>]</code>: </b>sets maximum alignment to <code>n</code>
8833 <li><b><code>b</code>: </b>a signed byte (<code>char</code>)</li>
8834 <li><b><code>B</code>: </b>an unsigned byte (<code>char</code>)</li>
8835 <li><b><code>h</code>: </b>a signed <code>short</code> (native size)</li>
8836 <li><b><code>H</code>: </b>an unsigned <code>short</code> (native size)</li>
8837 <li><b><code>l</code>: </b>a signed <code>long</code> (native size)</li>
8838 <li><b><code>L</code>: </b>an unsigned <code>long</code> (native size)</li>
8839 <li><b><code>j</code>: </b>a <code>lua_Integer</code></li>
8840 <li><b><code>J</code>: </b>a <code>lua_Unsigned</code></li>
8841 <li><b><code>T</code>: </b>a <code>size_t</code> (native size)</li>
8842 <li><b><code>i[<em>n</em>]</code>: </b>a signed <code>int</code> with <code>n</code> bytes
8844 <li><b><code>I[<em>n</em>]</code>: </b>an unsigned <code>int</code> with <code>n</code> bytes
8846 <li><b><code>f</code>: </b>a <code>float</code> (native size)</li>
8847 <li><b><code>d</code>: </b>a <code>double</code> (native size)</li>
8848 <li><b><code>n</code>: </b>a <code>lua_Number</code></li>
8849 <li><b><code>c<em>n</em></code>: </b>a fixed-sized string with <code>n</code> bytes</li>
8850 <li><b><code>z</code>: </b>a zero-terminated string</li>
8851 <li><b><code>s[<em>n</em>]</code>: </b>a string preceded by its length
8852 coded as an unsigned integer with <code>n</code> bytes
8853 (default is a <code>size_t</code>)</li>
8854 <li><b><code>x</code>: </b>one byte of padding</li>
8855 <li><b><code>X<em>op</em></code>: </b>an empty item that aligns
8856 according to option <code>op</code>
8858 <li><b>'<code> </code>': </b>(empty space) ignored</li>
8860 (A "<code>[<em>n</em>]</code>" means an optional integral numeral.)
8862 (options "<code>xX &lt;=&gt;!</code>"),
8863 each option corresponds to an argument (in <a href="#pdf-string.pack"><code>string.pack</code></a>)
8864 or a result (in <a href="#pdf-string.unpack"><code>string.unpack</code></a>).
8868 For options "<code>!<em>n</em></code>", "<code>s<em>n</em></code>", "<code>i<em>n</em></code>", and…
8869 <code>n</code> can be any integer between 1 and 16.
8871 <a href="#pdf-string.pack"><code>string.pack</code></a> checks whether the given value fits in the …
8872 <a href="#pdf-string.unpack"><code>string.unpack</code></a> checks whether the read value fits in a…
8876 Any format string starts as if prefixed by "<code>!1=</code>",
8889 Options "<code>c</code>" and "<code>z</code>" are not aligned;
8890 option "<code>s</code>" follows the alignment of its starting integer.
8894 All padding is filled with zeros by <a href="#pdf-string.pack"><code>string.pack</code></a>
8895 (and ignored by <a href="#pdf-string.unpack"><code>string.unpack</code></a>).
8907 It provides all its functions inside the table <a name="pdf-utf8"><code>utf8</code></a>.
8924 <hr><h3><a name="pdf-utf8.char"><code>utf8.char (&middot;&middot;&middot;)</code></a></h3>
8933 <hr><h3><a name="pdf-utf8.charpattern"><code>utf8.charpattern</code></a></h3>
8934 The pattern (a string, not a function) "<code>[\0-\x7F\xC2-\xF4][\x80-\xBF]*</code>"
8943 <hr><h3><a name="pdf-utf8.codes"><code>utf8.codes (s)</code></a></h3>
8952 will iterate over all characters in string <code>s</code>,
8953 with <code>p</code> being the position (in bytes) and <code>c</code> the code point
8961 <hr><h3><a name="pdf-utf8.codepoint"><code>utf8.codepoint (s [, i [, j]])</code></a></h3>
8962 Returns the codepoints (as integers) from all characters in <code>s</code>
8963 that start between byte position <code>i</code> and <code>j</code> (both included).
8964 The default for <code>i</code> is 1 and for <code>j</code> is <code>i</code>.
8971 <hr><h3><a name="pdf-utf8.len"><code>utf8.len (s [, i [, j]])</code></a></h3>
8972 Returns the number of UTF-8 characters in string <code>s</code>
8973 that start between positions <code>i</code> and <code>j</code> (both inclusive).
8974 The default for <code>i</code> is 1 and for <code>j</code> is -1.
8982 <hr><h3><a name="pdf-utf8.offset"><code>utf8.offset (s, n [, i])</code></a></h3>
8984 <code>n</code>-th character of <code>s</code>
8985 (counting from position <code>i</code>) starts.
8986 A negative <code>n</code> gets characters before position <code>i</code>.
8987 The default for <code>i</code> is 1 when <code>n</code> is non-negative
8988 and <code>#s + 1</code> otherwise,
8989 so that <code>utf8.offset(s, -n)</code> gets the offset of the
8990 <code>n</code>-th character from the end of the string.
8998 when <code>n</code> is 0 the function returns the start of the encoding
8999 of the character that contains the <code>i</code>-th byte of <code>s</code>.
9003 This function assumes that <code>s</code> is a valid UTF-8 string.
9015 It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.
9026 <hr><h3><a name="pdf-table.concat"><code>table.concat (list [, sep [, i [, j]]])</code></a></h3>
9031 returns the string <code>list[i]..sep..list[i+1] &middot;&middot;&middot; sep..list[j]</code>.
9032 The default value for <code>sep</code> is the empty string,
9033 the default for <code>i</code> is 1,
9034 and the default for <code>j</code> is <code>#list</code>.
9035 If <code>i</code> is greater than <code>j</code>, returns the empty string.
9041 <hr><h3><a name="pdf-table.insert"><code>table.insert (list, [pos,] value)</code></a></h3>
9045 Inserts element <code>value</code> at position <code>pos</code> in <code>list</code>,
9047 <code>list[pos], list[pos+1], &middot;&middot;&middot;, list[#list]</code>.
9048 The default value for <code>pos</code> is <code>#list+1</code>,
9049 so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
9050 of list <code>t</code>.
9056 <hr><h3><a name="pdf-table.move"><code>table.move (a1, f, e, t [,a2])</code></a></h3>
9060 Moves elements from table <code>a1</code> to table <code>a2</code>,
9063 <code>a2[t],&middot;&middot;&middot; = a1[f],&middot;&middot;&middot;,a1[e]</code>.
9064 The default for <code>a2</code> is <code>a1</code>.
9070 Returns the destination table <code>a2</code>.
9076 <hr><h3><a name="pdf-table.pack"><code>table.pack (&middot;&middot;&middot;)</code></a></h3>
9081 and with a field "<code>n</code>" with the total number of arguments.
9088 <hr><h3><a name="pdf-table.remove"><code>table.remove (list [, pos])</code></a></h3>
9092 Removes from <code>list</code> the element at position <code>pos</code>,
9094 When <code>pos</code> is an integer between 1 and <code>#list</code>,
9096 <code>list[pos+1], list[pos+2], &middot;&middot;&middot;, list[#list]</code>
9097 and erases element <code>list[#list]</code>;
9098 The index <code>pos</code> can also be 0 when <code>#list</code> is 0,
9099 or <code>#list + 1</code>;
9100 in those cases, the function erases the element <code>list[pos]</code>.
9104 The default value for <code>pos</code> is <code>#list</code>,
9105 so that a call <code>table.remove(l)</code> removes the last element
9106 of list <code>l</code>.
9112 <hr><h3><a name="pdf-table.sort"><code>table.sort (list [, comp])</code></a></h3>
9117 from <code>list[1]</code> to <code>list[#list]</code>.
9118 If <code>comp</code> is given,
9123 <code>i &lt; j</code> implies <code>not comp(list[j],list[i])</code>).
9124 If <code>comp</code> is not given,
9125 then the standard Lua operator <code>&lt;</code> is used instead.
9129 Note that the <code>comp</code> function must define
9144 <hr><h3><a name="pdf-table.unpack"><code>table.unpack (list [, i [, j]])</code></a></h3>
9154 By default, <code>i</code> is&nbsp;1 and <code>j</code> is <code>#list</code>.
9166 It provides all its functions and constants inside the table <a name="pdf-math"><code>math</code></…
9167 Functions with the annotation "<code>integer/float</code>" give
9171 …th.ceil"><code>math.ceil</code></a>, <a href="#pdf-math.floor"><code>math.floor</code></a>, and <a…
9177 <hr><h3><a name="pdf-math.abs"><code>math.abs (x)</code></a></h3>
9181 Returns the absolute value of <code>x</code>. (integer/float)
9187 <hr><h3><a name="pdf-math.acos"><code>math.acos (x)</code></a></h3>
9191 Returns the arc cosine of <code>x</code> (in radians).
9197 <hr><h3><a name="pdf-math.asin"><code>math.asin (x)</code></a></h3>
9201 Returns the arc sine of <code>x</code> (in radians).
9207 <hr><h3><a name="pdf-math.atan"><code>math.atan (y [, x])</code></a></h3>
9212 Returns the arc tangent of <code>y/x</code> (in radians),
9215 (It also handles correctly the case of <code>x</code> being zero.)
9219 The default value for <code>x</code> is 1,
9220 so that the call <code>math.atan(y)</code>
9221 returns the arc tangent of <code>y</code>.
9227 <hr><h3><a name="pdf-math.ceil"><code>math.ceil (x)</code></a></h3>
9231 Returns the smallest integral value larger than or equal to <code>x</code>.
9237 <hr><h3><a name="pdf-math.cos"><code>math.cos (x)</code></a></h3>
9241 Returns the cosine of <code>x</code> (assumed to be in radians).
9247 <hr><h3><a name="pdf-math.deg"><code>math.deg (x)</code></a></h3>
9251 Converts the angle <code>x</code> from radians to degrees.
9257 <hr><h3><a name="pdf-math.exp"><code>math.exp (x)</code></a></h3>
9262 (where <code>e</code> is the base of natural logarithms).
9268 <hr><h3><a name="pdf-math.floor"><code>math.floor (x)</code></a></h3>
9272 Returns the largest integral value smaller than or equal to <code>x</code>.
9278 <hr><h3><a name="pdf-math.fmod"><code>math.fmod (x, y)</code></a></h3>
9282 Returns the remainder of the division of <code>x</code> by <code>y</code>
9289 <hr><h3><a name="pdf-math.huge"><code>math.huge</code></a></h3>
9293 The float value <code>HUGE_VAL</code>,
9300 <hr><h3><a name="pdf-math.log"><code>math.log (x [, base])</code></a></h3>
9304 Returns the logarithm of <code>x</code> in the given base.
9305 The default for <code>base</code> is <em>e</em>
9306 (so that the function returns the natural logarithm of <code>x</code>).
9312 <hr><h3><a name="pdf-math.max"><code>math.max (x, &middot;&middot;&middot;)</code></a></h3>
9317 according to the Lua operator <code>&lt;</code>. (integer/float)
9323 <hr><h3><a name="pdf-math.maxinteger"><code>math.maxinteger</code></a></h3>
9330 <hr><h3><a name="pdf-math.min"><code>math.min (x, &middot;&middot;&middot;)</code></a></h3>
9335 according to the Lua operator <code>&lt;</code>. (integer/float)
9341 <hr><h3><a name="pdf-math.mininteger"><code>math.mininteger</code></a></h3>
9348 <hr><h3><a name="pdf-math.modf"><code>math.modf (x)</code></a></h3>
9352 Returns the integral part of <code>x</code> and the fractional part of <code>x</code>.
9359 <hr><h3><a name="pdf-math.pi"><code>math.pi</code></a></h3>
9369 <hr><h3><a name="pdf-math.rad"><code>math.rad (x)</code></a></h3>
9373 Converts the angle <code>x</code> from degrees to radians.
9379 <hr><h3><a name="pdf-math.random"><code>math.random ([m [, n]])</code></a></h3>
9386 When called with two integers <code>m</code> and <code>n</code>,
9387 <code>math.random</code> returns a pseudo-random integer
9390 The call <code>math.random(n)</code> is equivalent to <code>math.random(1,n)</code>.
9401 <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed (x)</code></a></h3>
9405 Sets <code>x</code> as the "seed"
9413 <hr><h3><a name="pdf-math.sin"><code>math.sin (x)</code></a></h3>
9417 Returns the sine of <code>x</code> (assumed to be in radians).
9423 <hr><h3><a name="pdf-math.sqrt"><code>math.sqrt (x)</code></a></h3>
9427 Returns the square root of <code>x</code>.
9428 (You can also use the expression <code>x^0.5</code> to compute this value.)
9434 <hr><h3><a name="pdf-math.tan"><code>math.tan (x)</code></a></h3>
9438 Returns the tangent of <code>x</code> (assumed to be in radians).
9444 <hr><h3><a name="pdf-math.tointeger"><code>math.tointeger (x)</code></a></h3>
9448 If the value <code>x</code> is convertible to an integer,
9456 <hr><h3><a name="pdf-math.type"><code>math.type (x)</code></a></h3>
9460 Returns "<code>integer</code>" if <code>x</code> is an integer,
9461 "<code>float</code>" if it is a float,
9462 or <b>nil</b> if <code>x</code> is not a number.
9468 <hr><h3><a name="pdf-math.ult"><code>math.ult (m, n)</code></a></h3>
9473 true if and only if integer <code>m</code> is below integer <code>n</code> when
9495 all operations are supplied by table <a name="pdf-io"><code>io</code></a>.
9497 the operation <a href="#pdf-io.open"><code>io.open</code></a> returns a file handle
9502 The table <code>io</code> also provides
9504 …f-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a>, and <a …
9512 a system-dependent error code as a third result)
9515 the computation of the error message and error code
9518 because they rely on the global C variable <code>errno</code>.
9522 <hr><h3><a name="pdf-io.close"><code>io.close ([file])</code></a></h3>
9526 Equivalent to <code>file:close()</code>.
9527 Without a <code>file</code>, closes the default output file.
9533 <hr><h3><a name="pdf-io.flush"><code>io.flush ()</code></a></h3>
9537 Equivalent to <code>io.output():flush()</code>.
9543 <hr><h3><a name="pdf-io.input"><code>io.input ([file])</code></a></h3>
9557 instead of returning an error code.
9563 <hr><h3><a name="pdf-io.lines"><code>io.lines ([filename, &middot;&middot;&middot;])</code></a></h3>
9569 works like <code>file:lines(&middot;&middot;&middot;)</code> over the opened file.
9575 The call <code>io.lines()</code> (with no file name) is equivalent
9576 to <code>io.input():lines("*l")</code>;
9583 instead of returning an error code.
9589 <hr><h3><a name="pdf-io.open"><code>io.open (filename [, mode])</code></a></h3>
9594 in the mode specified in the string <code>mode</code>.
9600 The <code>mode</code> string can be any of the following:
9603 <li><b>"<code>r</code>": </b> read mode (the default);</li>
9604 <li><b>"<code>w</code>": </b> write mode;</li>
9605 <li><b>"<code>a</code>": </b> append mode;</li>
9606 <li><b>"<code>r+</code>": </b> update mode, all previous data is preserved;</li>
9607 <li><b>"<code>w+</code>": </b> update mode, all previous data is erased;</li>
9608 <li><b>"<code>a+</code>": </b> append update mode, previous data is preserved,
9611 The <code>mode</code> string can also have a '<code>b</code>' at the end,
9618 <hr><h3><a name="pdf-io.output"><code>io.output ([file])</code></a></h3>
9622 Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output …
9628 <hr><h3><a name="pdf-io.popen"><code>io.popen (prog [, mode])</code></a></h3>
9637 Starts program <code>prog</code> in a separated process and returns
9639 (if <code>mode</code> is <code>"r"</code>, the default)
9641 (if <code>mode</code> is <code>"w"</code>).
9647 <hr><h3><a name="pdf-io.read"><code>io.read (&middot;&middot;&middot;)</code></a></h3>
9651 Equivalent to <code>io.input():read(&middot;&middot;&middot;)</code>.
9657 <hr><h3><a name="pdf-io.tmpfile"><code>io.tmpfile ()</code></a></h3>
9670 <hr><h3><a name="pdf-io.type"><code>io.type (obj)</code></a></h3>
9674 Checks whether <code>obj</code> is a valid file handle.
9675 Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,
9676 <code>"closed file"</code> if <code>obj</code> is a closed file handle,
9677 or <b>nil</b> if <code>obj</code> is not a file handle.
9683 <hr><h3><a name="pdf-io.write"><code>io.write (&middot;&middot;&middot;)</code></a></h3>
9687 Equivalent to <code>io.output():write(&middot;&middot;&middot;)</code>.
9693 <hr><h3><a name="pdf-file:close"><code>file:close ()</code></a></h3>
9697 Closes <code>file</code>.
9704 When closing a file handle created with <a href="#pdf-io.popen"><code>io.popen</code></a>,
9705 <a href="#pdf-file:close"><code>file:close</code></a> returns the same values
9706 returned by <a href="#pdf-os.execute"><code>os.execute</code></a>.
9712 <hr><h3><a name="pdf-file:flush"><code>file:flush ()</code></a></h3>
9716 Saves any written data to <code>file</code>.
9722 <hr><h3><a name="pdf-file:lines"><code>file:lines (&middot;&middot;&middot;)</code></a></h3>
9730 uses "<code>l</code>" as a default.
9738 Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
9744 instead of returning an error code.
9750 <hr><h3><a name="pdf-file:read"><code>file:read (&middot;&middot;&middot;)</code></a></h3>
9754 Reads the file <code>file</code>,
9771 <li><b>"<code>n</code>": </b>
9778 (e.g., an empty string, "<code>0x</code>", or "<code>3.4e-</code>"),
9782 <li><b>"<code>a</code>": </b>
9787 <li><b>"<code>l</code>": </b>
9793 <li><b>"<code>L</code>": </b>
9801 If <code>number</code> is zero,
9807 The formats "<code>l</code>" and "<code>L</code>" should be used only for text files.
9813 <hr><h3><a name="pdf-file:seek"><code>file:seek ([whence [, offset]])</code></a></h3>
9819 to the position given by <code>offset</code> plus a base
9820 specified by the string <code>whence</code>, as follows:
9823 <li><b>"<code>set</code>": </b> base is position 0 (beginning of the file);</li>
9824 <li><b>"<code>cur</code>": </b> base is current position;</li>
9825 <li><b>"<code>end</code>": </b> base is end of file;</li>
9827 In case of success, <code>seek</code> returns the final file position,
9829 If <code>seek</code> fails, it returns <b>nil</b>,
9834 The default value for <code>whence</code> is <code>"cur"</code>,
9835 and for <code>offset</code> is 0.
9836 Therefore, the call <code>file:seek()</code> returns the current
9838 the call <code>file:seek("set")</code> sets the position to the
9840 and the call <code>file:seek("end")</code> sets the position to the
9847 <hr><h3><a name="pdf-file:setvbuf"><code>file:setvbuf (mode [, size])</code></a></h3>
9856 <li><b>"<code>no</code>": </b>
9860 <li><b>"<code>full</code>": </b>
9863 you explicitly <code>flush</code> the file (see <a href="#pdf-io.flush"><code>io.flush</code></a>).
9866 <li><b>"<code>line</code>": </b>
9873 For the last two cases, <code>size</code>
9881 <hr><h3><a name="pdf-file:write"><code>file:write (&middot;&middot;&middot;)</code></a></h3>
9885 Writes the value of each of its arguments to <code>file</code>.
9890 In case of success, this function returns <code>file</code>.
9902 This library is implemented through table <a name="pdf-os"><code>os</code></a>.
9906 <hr><h3><a name="pdf-os.clock"><code>os.clock ()</code></a></h3>
9917 <hr><h3><a name="pdf-os.date"><code>os.date ([format [, time]])</code></a></h3>
9922 formatted according to the given string <code>format</code>.
9926 If the <code>time</code> argument is present,
9928 (see the <a href="#pdf-os.time"><code>os.time</code></a> function for a description of this value).
9929 Otherwise, <code>date</code> formats the current time.
9933 If <code>format</code> starts with '<code>!</code>',
9936 if <code>format</code> is the string "<code>*t</code>",
9937 then <code>date</code> returns a table with the following fields:
9938 <code>year</code>, <code>month</code> (1&ndash;12), <code>day</code> (1&ndash;31),
9939 <code>hour</code> (0&ndash;23), <code>min</code> (0&ndash;59), <code>sec</code> (0&ndash;61),
9940 <code>wday</code> (weekday, 1&ndash;7, Sunday is&nbsp;1),
9941 <code>yday</code> (day of the year, 1&ndash;366),
9942 and <code>isdst</code> (daylight saving flag, a boolean).
9948 If <code>format</code> is not "<code>*t</code>",
9949 then <code>date</code> returns the date as a string,
9950 formatted according to the same rules as the ISO&nbsp;C function <code>strftime</code>.
9955 <code>date</code> returns a reasonable date and time representation that depends on
9957 (More specifically, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>.)
9963 because of its reliance on C&nbsp;function <code>gmtime</code> and C&nbsp;function <code>localtime<…
9969 <hr><h3><a name="pdf-os.difftime"><code>os.difftime (t2, t1)</code></a></h3>
9974 from time <code>t1</code> to time <code>t2</code>
9975 (where the times are values returned by <a href="#pdf-os.time"><code>os.time</code></a>).
9977 this value is exactly <code>t2</code><em>-</em><code>t1</code>.
9983 <hr><h3><a name="pdf-os.execute"><code>os.execute ([command])</code></a></h3>
9987 This function is equivalent to the ISO&nbsp;C function <code>system</code>.
9988 It passes <code>command</code> to be executed by an operating system shell.
9998 <li><b>"<code>exit</code>": </b>
10003 <li><b>"<code>signal</code>": </b>
10011 When called without a <code>command</code>,
10012 <code>os.execute</code> returns a boolean that is true if a shell is available.
10018 <hr><h3><a name="pdf-os.exit"><code>os.exit ([code [, close]])</code></a></h3>
10022 Calls the ISO&nbsp;C function <code>exit</code> to terminate the host program.
10023 If <code>code</code> is <b>true</b>,
10024 the returned status is <code>EXIT_SUCCESS</code>;
10025 if <code>code</code> is <b>false</b>,
10026 the returned status is <code>EXIT_FAILURE</code>;
10027 if <code>code</code> is a number,
10029 The default value for <code>code</code> is <b>true</b>.
10033 If the optional second argument <code>close</code> is true,
10040 <hr><h3><a name="pdf-os.getenv"><code>os.getenv (varname)</code></a></h3>
10044 Returns the value of the process environment variable <code>varname</code>,
10051 <hr><h3><a name="pdf-os.remove"><code>os.remove (filename)</code></a></h3>
10058 plus a string describing the error and the error code.
10065 <hr><h3><a name="pdf-os.rename"><code>os.rename (oldname, newname)</code></a></h3>
10069 Renames the file or directory named <code>oldname</code> to <code>newname</code>.
10071 plus a string describing the error and the error code.
10078 <hr><h3><a name="pdf-os.setlocale"><code>os.setlocale (locale [, category])</code></a></h3>
10083 <code>locale</code> is a system-dependent string specifying a locale;
10084 <code>category</code> is an optional string describing which category to change:
10085 <code>"all"</code>, <code>"collate"</code>, <code>"ctype"</code>,
10086 <code>"monetary"</code>, <code>"numeric"</code>, or <code>"time"</code>;
10087 the default category is <code>"all"</code>.
10093 If <code>locale</code> is the empty string,
10095 If <code>locale</code> is the string "<code>C</code>",
10107 because of its reliance on C&nbsp;function <code>setlocale</code>.
10113 <hr><h3><a name="pdf-os.time"><code>os.time ([table])</code></a></h3>
10119 This table must have fields <code>year</code>, <code>month</code>, and <code>day</code>,
10121 <code>hour</code> (default is 12),
10122 <code>min</code> (default is 0),
10123 <code>sec</code> (default is 0),
10124 and <code>isdst</code> (default is <b>nil</b>).
10126 For a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function.
10131 For instance, if <code>sec</code> is -10,
10133 if <code>hour</code> is 1000,
10143 and the number returned by <code>time</code> can be used only as an argument to
10144 <a href="#pdf-os.date"><code>os.date</code></a> and <a href="#pdf-os.difftime"><code>os.difftime</c…
10150 <hr><h3><a name="pdf-os.tmpname"><code>os.tmpname ()</code></a></h3>
10172 you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
10188 violate basic assumptions about Lua code
10191 that userdata metatables cannot be changed by Lua code;
10193 and therefore can compromise otherwise secure code.
10199 inside the <a name="pdf-debug"><code>debug</code></a> table.
10207 <hr><h3><a name="pdf-debug.debug"><code>debug.debug ()</code></a></h3>
10216 A line containing only the word <code>cont</code> finishes this function,
10221 Note that commands for <code>debug.debug</code> are not lexically nested
10228 <hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
10235 (as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).
10241 <hr><h3><a name="pdf-debug.getinfo"><code>debug.getinfo ([thread,] f [, what])</code></a></h3>
10247 or you can give a number as the value of <code>f</code>,
10248 which means the function running at level <code>f</code> of the call stack
10250 level&nbsp;0 is the current function (<code>getinfo</code> itself);
10251 level&nbsp;1 is the function that called <code>getinfo</code>
10254 If <code>f</code> is a number larger than the number of active functions,
10255 then <code>getinfo</code> returns <b>nil</b>.
10259 …d table can contain all the fields returned by <a href="#lua_getinfo"><code>lua_getinfo</code></a>,
10260 with the string <code>what</code> describing which fields to fill in.
10261 The default for <code>what</code> is to get all information available,
10264 the option '<code>f</code>'
10265 adds a field named <code>func</code> with the function itself.
10267 the option '<code>L</code>'
10268 adds a field named <code>activelines</code> with the table of
10273 For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
10276 and the expression <code>debug.getinfo(print)</code>
10278 about the <a href="#pdf-print"><code>print</code></a> function.
10284 <hr><h3><a name="pdf-debug.getlocal"><code>debug.getlocal ([thread,] f, local)</code></a></h3>
10289 with index <code>local</code> of the function at level <code>f</code> of the stack.
10296 following the order that they are declared in the code,
10303 (You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the leve…
10307 Variable names starting with '<code>(</code>' (open parenthesis)
10314 The parameter <code>f</code> may also be a function.
10315 In that case, <code>getlocal</code> returns only the name of function parameters.
10321 <hr><h3><a name="pdf-debug.getmetatable"><code>debug.getmetatable (value)</code></a></h3>
10325 Returns the metatable of the given <code>value</code>
10332 <hr><h3><a name="pdf-debug.getregistry"><code>debug.getregistry ()</code></a></h3>
10342 <hr><h3><a name="pdf-debug.getupvalue"><code>debug.getupvalue (f, up)</code></a></h3>
10347 with index <code>up</code> of the function <code>f</code>.
10352 Variable names starting with '<code>(</code>' (open parenthesis)
10360 <hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3>
10364 Returns the Lua value associated to <code>u</code>.
10365 If <code>u</code> is not a full userdata,
10372 <hr><h3><a name="pdf-debug.sethook"><code>debug.sethook ([thread,] hook, mask [, count])</code></a>…
10377 The string <code>mask</code> and the number <code>count</code> describe
10383 <li><b>'<code>c</code>': </b> the hook is called every time Lua calls a function;</li>
10384 <li><b>'<code>r</code>': </b> the hook is called every time Lua returns from a function;</li>
10385 <li><b>'<code>l</code>': </b> the hook is called every time Lua enters a new line of code.</li>
10388 with a <code>count</code> different from zero,
10389 the hook is called also after every <code>count</code> instructions.
10394 <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> turns off the hook.
10400 <code>"call"</code> (or <code>"tail call"</code>),
10401 <code>"return"</code>,
10402 <code>"line"</code>, and <code>"count"</code>.
10406 you can call <code>getinfo</code> with level&nbsp;2 to get more information about
10408 (level&nbsp;0 is the <code>getinfo</code> function,
10415 <hr><h3><a name="pdf-debug.setlocal"><code>debug.setlocal ([thread,] level, local, value)</code></a…
10419 This function assigns the value <code>value</code> to the local variable
10420 with index <code>local</code> of the function at level <code>level</code> of the stack.
10423 and raises an error when called with a <code>level</code> out of range.
10424 (You can call <code>getinfo</code> to check whether the level is valid.)
10429 See <a href="#pdf-debug.getlocal"><code>debug.getlocal</code></a> for more information about
10436 <hr><h3><a name="pdf-debug.setmetatable"><code>debug.setmetatable (value, table)</code></a></h3>
10440 Sets the metatable for the given <code>value</code> to the given <code>table</code>
10442 Returns <code>value</code>.
10448 <hr><h3><a name="pdf-debug.setupvalue"><code>debug.setupvalue (f, up, value)</code></a></h3>
10452 This function assigns the value <code>value</code> to the upvalue
10453 with index <code>up</code> of the function <code>f</code>.
10462 <hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3>
10466 Sets the given <code>value</code> as
10467 the Lua value associated to the given <code>udata</code>.
10468 <code>udata</code> must be a full userdata.
10472 Returns <code>udata</code>.
10478 <hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code><…
10482 If <code>message</code> is present but is neither a string nor <b>nil</b>,
10483 this function returns <code>message</code> without further processing.
10486 The optional <code>message</code> string is appended
10488 An optional <code>level</code> number tells at which level
10490 (default is 1, the function calling <code>traceback</code>).
10496 <hr><h3><a name="pdf-debug.upvalueid"><code>debug.upvalueid (f, n)</code></a></h3>
10501 for the upvalue numbered <code>n</code>
10516 <hr><h3><a name="pdf-debug.upvaluejoin"><code>debug.upvaluejoin (f1, n1, f2, n2)</code></a></h3>
10520 Make the <code>n1</code>-th upvalue of the Lua closure <code>f1</code>
10521 refer to the <code>n2</code>-th upvalue of the Lua closure <code>f2</code>.
10536 called simply <code>lua</code>,
10548 <li><b><code>-e <em>stat</em></code>: </b> executes string <em>stat</em>;</li>
10549 <li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em> and assigns the
10551 <li><b><code>-i</code>: </b> enters interactive mode after running <em>script</em>;</li>
10552 <li><b><code>-v</code>: </b> prints version information;</li>
10553 <li><b><code>-E</code>: </b> ignores environment variables;</li>
10554 <li><b><code>--</code>: </b> stops handling options;</li>
10555 <li><b><code>-</code>: </b> executes <code>stdin</code> as a file and stops handling options.</li>
10557 After handling its options, <code>lua</code> runs the given <em>script</em>.
10559 <code>lua</code> behaves as <code>lua -v -i</code>
10560 when the standard input (<code>stdin</code>) is a terminal,
10561 and as <code>lua -</code> otherwise.
10565 When called without option <code>-E</code>,
10566 …rpreter checks for an environment variable <a name="pdf-LUA_INIT_5_3"><code>LUA_INIT_5_3</code></a>
10567 (or <a name="pdf-LUA_INIT"><code>LUA_INIT</code></a> if the versioned name is not defined)
10569 If the variable content has the format <code>@<em>filename</em></code>,
10570 then <code>lua</code> executes the file.
10571 Otherwise, <code>lua</code> executes the string itself.
10575 When called with option <code>-E</code>,
10576 besides ignoring <code>LUA_INIT</code>,
10578 the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>,
10580 <a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.cpath"><code>pa…
10581 with the default paths defined in <code>luaconf.h</code>.
10585 All options are handled in order, except <code>-i</code> and <code>-E</code>.
10591 will first set <code>a</code> to 1, then print the value of <code>a</code>,
10592 and finally run the file <code>script.lua</code> with no arguments.
10593 (Here <code>$</code> is the shell prompt. Your prompt may be different.)
10597 Before running any code,
10598 <code>lua</code> collects all command-line arguments
10599 in a global table called <code>arg</code>.
10626 will print "<code>-e</code>".
10629 <code>arg[1]</code>, &middot;&middot;&middot;, <code>arg[#arg]</code>.
10647 If the global variable <a name="pdf-_PROMPT"><code>_PROMPT</code></a> contains a string,
10649 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a strin…
10658 has a metamethod <code>__tostring</code>,
10667 (see <a href="#lua_close"><code>lua_close</code></a>).
10669 calling <a href="#pdf-os.exit"><code>os.exit</code></a> to terminate.
10676 the first line of a chunk if it starts with <code>#</code>.
10678 by using <code>chmod +x</code> and the&nbsp;<code>#!</code> form,
10686 If <code>lua</code> is in your <code>PATH</code>,
10702 appropriate options (see file <code>luaconf.h</code>).
10709 do not imply source-code changes in a program,
10746 in particular writing constants with an ending <code>.0</code>
10747 or using <code>x = x + 0.0</code> to convert a variable.
10757 The conversion of a float to a string now adds a <code>.0</code> suffix
10759 (For instance, the float 2.0 will be printed as <code>2.0</code>,
10760 not as <code>2</code>.)
10785 The <code>bit32</code> library has been deprecated.
10788 (Keep in mind that <code>bit32</code> operates on 32-bit integers,
10799 The <a href="#pdf-ipairs"><code>ipairs</code></a> iterator now respects metamethods and
10800 its <code>__ipairs</code> metamethod has been deprecated.
10804 Option names in <a href="#pdf-io.read"><code>io.read</code></a> do not have a starting '<code>*</co…
10810 <code>atan2</code>, <code>cosh</code>, <code>sinh</code>, <code>tanh</code>, <code>pow</code>,
10811 <code>frexp</code>, and <code>ldexp</code>.
10812 You can replace <code>math.pow(x,y)</code> with <code>x^y</code>;
10813 you can replace <code>math.atan2</code> with <code>math.atan</code>,
10815 you can replace <code>math.ldexp(x,exp)</code> with <code>x * 2.0^exp</code>.
10822 The searcher for C loaders used by <a href="#pdf-require"><code>require</code></a>
10833 The call <code>collectgarbage("count")</code> now returns only one result.
10850 to get through <code>lua_getctx</code>,
10851 so <code>lua_getctx</code> has been removed.
10852 Adapt your code accordingly.
10856 Function <a href="#lua_dump"><code>lua_dump</code></a> has an extra parameter, <code>strip</code>.
10862 (<code>lua_pushunsigned</code>, <code>lua_tounsigned</code>, <code>lua_tounsignedx</code>,
10863 <code>luaL_checkunsigned</code>, <code>luaL_optunsigned</code>)
10870 (<code>luaL_checkint</code>, <code>luaL_optint</code>, <code>luaL_checklong</code>, <code>luaL_optl…
10872 Use their equivalent over <a href="#lua_Integer"><code>lua_Integer</code></a> with a type cast
10873 (or, when possible, use <a href="#lua_Integer"><code>lua_Integer</code></a> in your code).