Lines Matching full:in

53 Lua is implemented as a library, written in <em>clean</em> C
54 (that is, in the common subset of ANSI&nbsp;C and C++).
59 it only works <em>embedded</em> in a host client,
74 as stated in its license.
75 The implementation described in this manual is available
81 this document is dry in places.
84 For a detailed introduction to programming in Lua,
85 see Roberto's book, <em>Programming in Lua (Second Edition)</em>.
93 In other words,
102 in which
108 The complete syntax of Lua can be found in <a href="#8">&sect;8</a>
118 in Lua can be any string of letters,
121 This coincides with the definition of names in most languages.
124 can be used in an identifier.)
136 in local nil not or
174 results in a newline in the string.
175 A character in a string can also be specified by its numerical value
180 Strings in Lua can contain any 8-bit value, including embedded zeros,
197 Literals in this bracketed form can run for several lines,
206 the newline is not included in the string.
207 As an example, in a system using ASCII
208 (in which '<code>a</code>' is coded as&nbsp;97,
254 There are no type definitions in the language.
259 All values in Lua are <em>first-class values</em>.
260 This means that all values can be stored in variables,
265 There are eight basic types in Lua:
288 Lua can call (and manipulate) functions written in Lua and
289 functions written in C
295 be stored in Lua variables.
297 and has no pre-defined operations in Lua,
302 Userdata values cannot be created or modified in Lua,
321 Tables are the sole data structuring mechanism in Lua;
327 There are several convenient ways to create tables in Lua
334 In particular,
363 the number is converted to a string, in a reasonable format.
379 There are three kinds of variables in Lua:
391 Name denotes identifiers, as defined in <a href="#2.1">&sect;2.1</a>.
418 This function is not defined or callable in Lua.
431 All global variables live as fields in ordinary Lua tables,
435 so that all global variables in this function
450 which in turn is equivalent to
458 This function is not defined or callable in Lua.
459 Similarly, the <code>_env</code> variable is not defined in Lua.
470 similar to those in Pascal or C.
500 A chunk can be stored in a file or in a string inside the host program.
510 Programs in source and compiled forms are interchangeable;
535 add a <b>return</b> or <b>break</b> statement in the middle
549 The elements in both lists are separated by commas:
556 Expressions are discussed in <a href="#2.5">&sect;2.5</a>.
570 (except when the call is enclosed in parentheses; see <a href="#2.5">&sect;2.5</a>).
583 because the <code>i</code> in <code>a[i]</code> is evaluated (to 3)
606 This function is not defined or callable in Lua.
614 which in turn is equivalent to
620 (The <code>_env</code> variable is not defined in Lua.
640 Lua also has a <b>for</b> statement, in two flavors (see <a href="#2.4.5">&sect;2.4.5</a>).
648 (in particular, the number 0 and the empty string are also true).
652 In the <b>repeat</b>&ndash;<b>until</b> loop,
685 If it is really necessary to <b>return</b> or <b>break</b> in the
688 as in the idioms
690 because now <b>return</b> and <b>break</b> are the last statements in
741 They must all result in numbers.
775 stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
781 …for <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> in <em>explist</em> do <em>block</em>…
835 In this case, all returned values are thrown away.
836 Function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>.
856 and so local variables can be declared in a chunk outside any explicit block.
861 The visibility rules for local variables are explained in <a href="#2.6">&sect;2.6</a>.
872 The basic expressions in Lua are the following:
888 Numbers and literal strings are explained in <a href="#2.1">&sect;2.1</a>;
889 variables are explained in <a href="#2.3">&sect;2.3</a>;
890 function definitions are explained in <a href="#2.5.9">&sect;2.5.9</a>;
891 function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>;
892 table constructors are explained in <a href="#2.5.7">&sect;2.5.7</a>.
896 they are explained in <a href="#2.5.9">&sect;2.5.9</a>.
909 Both function calls and vararg expressions can result in multiple values.
917 (unless the call is enclosed in parentheses).
918 In all other contexts,
946 Any expression enclosed in parentheses always results in only one value.
979 The relational operators in Lua are
984 These operators always result in <b>false</b> or <b>true</b>.
991 Numbers and strings are compared in the usual way.
1010 entries in a table.
1032 The logical operators in Lua are
1062 (In this manual,
1070 The string concatenation operator in Lua is
1073 strings according to the rules mentioned in <a href="#2.2.1">&sect;2.2.1</a>.
1109 Operator precedence in Lua follows the table below,
1154 Fields in the other formats do not affect this counting.
1177 If the last field in the list has the form <code>exp</code>
1183 in parentheses (see <a href="#2.5">&sect;2.5</a>).
1195 A function call in Lua has the following syntax:
1200 In a function call,
1243 you cannot put a line break before the '<code>(</code>' in a function call.
1244 This restriction avoids some ambiguities in the language.
1262 in a tail call,
1376 or in the middle of a list of expressions,
1380 (unless that last expression is enclosed in parentheses).
1462 Notice that, in a declaration like <code>local x = x</code>,
1463 the new <code>x</code> being declared is not in scope yet,
1502 all Lua actions start from C&nbsp;code in the host program
1513 If you need to catch errors in Lua,
1523 Every value in Lua can have a <em>metatable</em>.
1528 of operations over a value by setting specific fields in its metatable.
1530 Lua checks for a function in the field <code>"__add"</code> in its metatable.
1536 We call the keys in a metatable <em>events</em>
1538 In the previous example, the event is <code>"add"</code>
1565 A metatable controls how an object behaves in arithmetic operations,
1589 The code shown here in Lua is only illustrative;
1590 the real behavior is hard coded in the interpreter
1592 All functions used in these descriptions
1594 are described in <a href="#5.1">&sect;5.1</a>.
1595 In particular, to retrieve the metamethod of a given object,
1609 (it simply results in <b>nil</b>).
1843 Note that, in the absence of a "le" metamethod,
2018 A value of 200 means that the collector waits for the total memory in use
2029 can result in the collector never finishing a cycle.
2035 You can change these numbers by calling <a href="#lua_gc"><code>lua_gc</code></a> in C
2036 or <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> in Lua.
2055 Garbage userdata with a field <code>__gc</code> in their metatables are not
2057 Instead, Lua puts them in a list.
2060 for each userdata in that list:
2073 the finalizers for userdata are called in <em>reverse</em>
2075 among those collected in that cycle.
2077 with the userdata created last in the program.
2078 The userdata itself is freed only in the next garbage-collection cycle.
2090 In other words,
2101 In any case, if either the key or the value is collected,
2106 the keys in the table are weak.
2108 the values in the table are weak.
2128 A coroutine in Lua represents an independent thread of execution.
2129 Unlike threads in multithread systems, however,
2156 A coroutine can terminate its execution in two ways:
2160 In the first case, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>tru…
2162 In case of errors, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>fal…
2171 (that is, not in the main function,
2172 but in a function directly or indirectly called by the main function).
2173 In the case of a yield, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> also retu…
2244 are declared in the header file <a name="pdf-lua.h"><code>lua.h</code></a>.
2249 any facility in the API may be provided as a macro instead.
2256 As in most C&nbsp;libraries,
2260 in file <code>luaconf.h</code>.
2268 Each element in this stack represents a Lua value
2283 most query operations in the API do not follow a strict stack discipline.
2284 Instead, they can refer to any element in the stack
2311 In particular,
2350 but which are not in the stack.
2415 or a light userdata with the address of a C&nbsp;object in your code.
2419 The integer keys in the registry are used by the reference mechanism,
2427 <h2>3.6 - <a name="3.6">Error Handling in C</a></h2>
2444 Most functions in the API can throw an error,
2460 Here we list all functions and types from the C&nbsp;API in
2472 A field in the form <code>x|y</code> means the function can push (or pop)
2521 It is used in the auxiliary library by <a href="#luaL_newstate"><code>luaL_newstate</code></a>.
2580 in direct order;
2589 In this case, <em>all</em> results from the function are pushed.
2591 The function results are pushed onto the stack in direct order
2608 Here it is in&nbsp;C:
2636 In order to communicate properly with Lua,
2639 a C&nbsp;function receives its arguments from Lua in its stack
2640 in direct order (the first argument is pushed first).
2646 in direct order (the first result is pushed first),
2648 Any other value in the stack below the results will be properly
2684 Ensures that there are at least <code>extra</code> free stack slots in the stack.
2699 Destroys all objects in the given Lua state
2735 Calls the C&nbsp;function <code>func</code> in protected mode.
2736 <code>func</code> starts with only one element in its stack,
2738 In case of errors,
2773 results in a function equivalent to the one dumped.
2798 Returns 1 if the two values in acceptable indices <code>index1</code> and
2852 returns the current amount of memory (in Kbytes) in use by Lua.
2857 memory in use by Lua by 1024.
2863 (larger values mean more steps) in a non-specified way.
2893 If <code>ud</code> is not <code>NULL</code>, Lua stores in <code>*ud</code> the
2919 As in Lua, this function may trigger a metamethod
2968 (putting the resulting value in its place).
2969 As in Lua, this function may trigger a metamethod
2981 Returns the index of the top element in the stack.
2983 this result is equal to the number of elements in the stack
3230 which is used for error messages and in debug information (see <a href="#3.8">&sect;3.8</a>).
3247 simply passes to the allocator in every call.
3297 Userdata represent C&nbsp;values in Lua.
3323 If there are no more elements in the table,
3331 /* table is in the stack at index 't' */
3359 The type of numbers in Lua.
3360 By default, it is double, but that can be changed in <code>luaconf.h</code>.
3392 Calls a function in protected mode.
3397 in <a href="#lua_call"><code>lua_call</code></a>.
3415 (In the current implementation, this index cannot be a pseudo-index.)
3416 In case of runtime errors,
3429 The <a href="#lua_pcall"><code>lua_pcall</code></a> function returns 0 in case of success
3431 (defined in <code>lua.h</code>):
3517 Any function to be registered in Lua must
3554 '<code>%%</code>' (inserts a '<code>%</code>' in the string),
3587 Userdata represent C&nbsp;values in Lua.
3606 In these cases, it automatically provides the string length.
3710 Returns 1 if the two values in acceptable indices <code>index1</code> and
3849 Starts and resumes a coroutine in a given thread.
3865 or an error code in case of errors (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
3866 In case of errors,
3918 As in Lua, this function may trigger a metamethod
3967 As in Lua, this function may trigger a metamethod
3996 All information about a state is kept in this structure.
4001 every function in the library, except to <a href="#lua_newstate"><code>lua_newstate</code></a>,
4032 Like all tests in Lua,
4071 it is truncated in some non-specified way.
4089 <em>changes the actual value in the stack to a string</em>.
4098 after its last character (as in&nbsp;C),
4099 but can contain other zeros in its body.
4188 Returns the type of the value in the given acceptable index,
4192 defined in <code>lua.h</code>:
4276 When a C&nbsp;function calls <a href="#lua_yield"><code>lua_yield</code></a> in that way,
4291 Lua has no built-in debugging facilities.
4331 If the function was defined in a string,
4333 If the function was defined in a file,
4338 a "printable" version of <code>source</code>, to be used in error messages.
4354 In the latter case,
4366 Because functions in Lua are first-class values,
4369 while others can be stored only in a table field.
4445 (In that case,
4446 <code>lua_getinfo</code> pops the function in the top of the stack.)
4447 For instance, to know in which line a function <code>f</code> was defined,
4458 Each character in the string <code>what</code>
4464 <li><b>'<code>n</code>':</b> fills in the field <code>name</code> and <code>namewhat</code>;
4468 fills in the fields <code>source</code>, <code>short_src</code>,
4472 <li><b>'<code>l</code>':</b> fills in the field <code>currentline</code>;
4475 <li><b>'<code>u</code>':</b> fills in the field <code>nups</code>;
4495 (for instance, an invalid option in <code>what</code>).
4562 and that are consequently included in its closure.)
4566 <code>funcindex</code> points to the closure in the stack.
4569 So, they are numbered in an arbitrary order.)
4597 To get the value of any other field in <code>ar</code>,
4601 In the latter case, Lua is simulating a return from
4603 in this case, it is useless to call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
4649 or when it jumps back in the code (even to the same line).
4673 Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal<…
4698 Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>…
4726 are defined in header file <code>lauxlib.h</code> and
4731 All functions in the auxiliary library are built on
4737 Several functions in the auxiliary library are used to
4751 in alphabetical order.
4861 but it is an idiom to use it in C&nbsp;functions
4943 In this case this function returns 1 and pushes onto the
5040 searches for this string in the array <code>lst</code>
5042 Returns the index in the array where the string was found.
5055 (The usual convention in Lua libraries is
5128 or 1 in case of errors.
5146 or 1 in case of errors.
5168 but it is an idiom to use it in C&nbsp;functions
5196 in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
5228 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the
5247 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the file
5251 The first line in the file is ignored if it starts with a <code>#</code>.
5274 This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in
5304 In both cases pushes onto the stack the final value associated
5305 with <code>tname</code> in the registry.
5320 an error message to the standard error output in case of fatal
5479 in the table at index <code>t</code>,
5514 in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
5532 it simply registers all functions in the list <code>l</code>
5541 and registers on it all functions in the list <code>l</code>.
5542 If there is a table in <code>package.loaded[libname]</code> or in
5548 In any case the function leaves the table
5610 of the control at level <code>lvl</code> in the call stack.
5638 and others could be implemented in Lua itself,
5640 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
5686 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>
5697 If you do not include this library in your application,
5737 returns the total memory in use by Lua (in Kbytes).
5743 (larger values mean more steps) in a non-specified way.
5771 In case of errors, <code>dofile</code> propagates the error
5772 to its caller (that is, <code>dofile</code> does not run in protected mode).
5812 Returns the current environment in use by the function.
5847 for i,v in ipairs(t) do <em>body</em> end
5925 is an index in this table.
5932 or with <b>nil</b> in an empty table,
5935 In particular,
5940 The order in which the indices are enumerated is not specified,
5942 (To traverse a table in numeric order,
5949 you assign any value to a non-existent field in the table.
5951 In particular, you may clear existing fields.
5965 for k,v in pairs(t) do <em>body</em> end
5983 the given arguments in <em>protected mode</em>.
5989 In such case, <code>pcall</code> also returns all results from the call,
5991 In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.
6071 In this case, <code>setfenv</code> returns no values.
6106 In bases above&nbsp;10, the letter '<code>A</code>' (in either upper or lower case)
6109 In base 10 (the default), the number can have a decimal part,
6111 In other bases, only unsigned integers are accepted.
6119 converts it to a string in a reasonable format.
6184 <code>xpcall</code> calls function <code>f</code> in protected mode,
6192 In this case, <code>xpcall</code> also returns all results from the call,
6194 In case of any error,
6270 <code>"suspended"</code>, if the coroutine is suspended in a call to <code>yield</code>,
6292 In case of error, propagates the error.
6317 facilities for loading and building modules in Lua.
6318 It exports two of its functions directly in the global environment:
6320 Everything else is exported in a table <a name="pdf-package"><code>package</code></a>.
6329 If there is a table in <code>package.loaded[name]</code>,
6351 then <code>module</code> stores the module table in field <code>c</code> of
6390 path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
6392 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
6394 it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.loaders"><code>package.loaders</c…
6405 In any case, <code>require</code> returns the
6426 Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the …
6429 or a default path defined in <code>luaconf.h</code>.
6458 Each entry in this table is a <em>searcher function</em>.
6460 <a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
6470 The first searcher simply looks for a loader in the
6480 mark in the template by <code>filename</code>,
6482 "directory separator" (such as "<code>/</code>" in Unix);
6492 <code>/usr/local/foo/init.lua</code>, in that order.
6506 and <code>/usr/local/foo/init.so</code>, in that order.
6522 The fourth searcher tries an <em>all-in-one loader</em>.
6529 in our example, that would be <code>luaopen_a_b_c</code>.
6580 with a default path defined in <code>luaconf.h</code>,
6582 Any "<code>;;</code>" in the value of the environment variable
6621 When indexing a string in Lua, the first character is at position&nbsp;1
6622 (not at&nbsp;0, as in C).
6633 Therefore, you can use the string functions in object-oriented style.
6660 in which each character has the internal numerical code equal
6686 <code>pattern</code> in the string <code>s</code>.
6696 with no characters in <code>pattern</code> being considered "magic".
6702 then in a successful match
6712 following the description given in its first argument (which must be a string).
6719 The <code>q</code> option formats a string in a form suitable to be safely read
6723 and backslashes in the string
6758 then the whole match is produced in each call.
6766 for w in string.gmatch(s, "%a+") do
6778 for k, v in string.gmatch(s, "(%w+)=(%w+)") do
6793 in which all (or the first <code>n</code>, if given)
6804 any sequence in <code>repl</code> of the form <code>%<em>n</em></code>,
6821 in order;
6832 (that is, the original match is kept in the string).
6886 <code>pattern</code> in the string <code>s</code>.
6921 In particular,
6944 The following combinations are allowed in describing a character class:
6981 when used to represent itself in a pattern.
6986 characters in <em>set</em>.
6990 components in <em>set</em>.
6991 All other characters in <em>set</em> represent themselves.
7019 In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.
7032 which matches any single character in the class;
7037 which matches 0 or more repetitions of characters in the class.
7043 which matches 1 or more repetitions of characters in the class.
7049 which also matches 0 or more repetitions of characters in the class.
7056 which matches 0 or 1 occurrence of a character in the class;
7095 A pattern can contain sub-patterns enclosed in parentheses;
7100 For instance, in the pattern <code>"(a*(.)%w(%s*))"</code>,
7133 Most functions in the table library assume that the table
7156 Inserts element <code>value</code> at position <code>pos</code> in <code>table</code>,
7197 Sorts table elements in a given order, <em>in-place</em>,
7242 Returns the arc cosine of <code>x</code> (in radians).
7252 Returns the arc sine of <code>x</code> (in radians).
7262 Returns the arc tangent of <code>x</code> (in radians).
7272 Returns the arc tangent of <code>y/x</code> (in radians),
7295 Returns the cosine of <code>x</code> (assumed to be in radians).
7315 Returns the angle <code>x</code> (given in radians) in degrees.
7358 in the range <em>[0.5, 1)</em>
7462 Returns the angle <code>x</code> (given in degrees) in radians.
7480 in the range <em>[0,1)</em>.
7483 a uniform pseudo-random integer in the range <em>[1, m]</em>.
7486 integer in the range <em>[m, n]</em>.
7508 Returns the sine of <code>x</code> (assumed to be in radians).
7539 Returns the tangent of <code>x</code> (assumed to be in radians).
7617 When called with a file name, it opens the named file (in text mode),
7626 In case of errors this function raises the error,
7637 Opens the given file name in read mode
7644 for line in io.lines(filename) do <em>body</em> end
7655 In this case it does not close the file when the loop ends.
7666 in the mode specified in the string <code>mode</code>.
7668 or, in case of errors, <b>nil</b> plus an error message.
7684 which is needed in some systems to open the file in binary mode.
7685 This string is exactly what is used in the
7706 Starts program <code>prog</code> in a separated process and returns
7736 This file is opened in update mode
7799 for line in file:lines() do <em>body</em> end
7871 In case of success, function <code>seek</code> returns the final file position,
7872 measured in bytes from the beginning of the file.
7918 specifies the size of the buffer, in bytes.
7952 Returns an approximation of the amount in seconds of CPU time
7976 then the date is formatted in Coordinated Universal Time.
8008 In POSIX, Windows, and some other systems,
8121 In POSIX, Windows, and some other systems, this number counts the number
8123 In other systems, the meaning is not specified,
8146 in the time between getting the name and creating the file.)
8182 All functions in this library are provided
8250 with the string <code>what</code> describing which fields to fill in.
8379 In this case, Lua is only simulating the return,
8448 to be embedded in a host C&nbsp;program,
8487 All options are handled in order, except <code>-i</code>.
8500 <code>lua</code> collects all arguments in the command line
8501 in a global table called <code>arg</code>.
8508 For instance, in the call
8528 In interactive mode,
8541 or in any Lua programs by assigning to <code>_PROMPT</code>.
8557 script interpreter in Unix systems,
8562 as in
8568 the location of the Lua interpreter may be different in your machine.
8569 If <code>lua</code> is in your <code>PATH</code>,
8587 all these compatibility options will be removed in the next version of Lua.
8591 <h2>7.1 - <a name="7.1">Changes in the Language</a></h2>
8597 (See compile-time option <code>LUA_COMPAT_VARARG</code> in <code>luaconf.h</code>.)
8601 There was a subtle change in the scope of the implicit
8608 You can use the new syntax (<code>[=[<em>string</em>]=]</code>) in these cases.
8609 (See compile-time option <code>LUA_COMPAT_LSTR</code> in <code>luaconf.h</code>.)
8617 <h2>7.2 - <a name="7.2">Changes in the Libraries</a></h2>
8622 (See compile-time option <code>LUA_COMPAT_GFIND</code> in <code>luaconf.h</code>.)
8638 (See compile-time option <code>LUA_COMPAT_GETN</code> in <code>luaconf.h</code>.)
8643 (See compile-time option <code>LUA_COMPAT_LOADLIB</code> in <code>luaconf.h</code>.)
8648 (See compile-time option <code>LUA_COMPAT_MOD</code> in <code>luaconf.h</code>.)
8657 There were substantial changes in function <a href="#pdf-require"><code>require</code></a> due to
8675 <h2>7.3 - <a name="7.3">Changes in the API</a></h2>
8708 (In Lua&nbsp;5.0 it returned <code>NULL</code>.)
8719 Here is the complete syntax of Lua in extended BNF.
8738 <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b> |