diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-08-28 17:46:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-08-28 17:46:26 -0300 |
commit | 15791f93fed507f73ae58aa89b3e8770b4d69406 (patch) | |
tree | b0df8cead7535d86b69c3a94e55bc0863845fc34 | |
parent | d763b69740653e68aaddd72edf0bc0a34544415a (diff) | |
download | lua-15791f93fed507f73ae58aa89b3e8770b4d69406.tar.gz lua-15791f93fed507f73ae58aa89b3e8770b4d69406.tar.bz2 lua-15791f93fed507f73ae58aa89b3e8770b4d69406.zip |
lhf's corrections.
-rw-r--r-- | manual.tex | 332 |
1 files changed, 166 insertions, 166 deletions
@@ -1,4 +1,4 @@ | |||
1 | % $Id: manual.tex,v 1.17 1996/04/29 18:50:08 roberto Exp roberto $ | 1 | % $Id: manual.tex,v 1.18 1996/06/18 20:08:40 roberto Exp roberto $ |
2 | 2 | ||
3 | \documentstyle[fullpage,11pt,bnf]{article} | 3 | \documentstyle[fullpage,11pt,bnf]{article} |
4 | 4 | ||
@@ -28,13 +28,13 @@ Waldemar Celes Filho | |||
28 | \vspace{1.0ex}\\ | 28 | \vspace{1.0ex}\\ |
29 | %\small \tecgraf \ --- PUC-Rio\\ | 29 | %\small \tecgraf \ --- PUC-Rio\\ |
30 | \smallskip | 30 | \smallskip |
31 | \small\tt roberto,lhf,celes@icad.puc-rio.br | 31 | \small\tt lua@icad.puc-rio.br |
32 | \vspace{2.0ex}\\ | 32 | \vspace{2.0ex}\\ |
33 | %MCC 08/95 --- | 33 | %MCC 08/95 --- |
34 | \tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio | 34 | \tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio |
35 | } | 35 | } |
36 | 36 | ||
37 | \date{\small \verb$Date: 1996/04/29 18:50:08 $} | 37 | \date{\small \verb$Date: 1996/06/18 20:08:40 $} |
38 | 38 | ||
39 | \maketitle | 39 | \maketitle |
40 | 40 | ||
@@ -42,9 +42,10 @@ Waldemar Celes Filho | |||
42 | \noindent | 42 | \noindent |
43 | Lua is an extension programming language designed to be used | 43 | Lua is an extension programming language designed to be used |
44 | as a configuration language for any program that needs one. | 44 | as a configuration language for any program that needs one. |
45 | This document describes Version \Version\ of the Lua programming language and | 45 | This document describes version \Version\ of the Lua programming language and |
46 | the API that allows interaction between Lua programs and its host C program. | 46 | the API that allows interaction between Lua programs and their host C programs. |
47 | It also presents some examples of using the main features of the system. | 47 | The document also presents some examples of using the main |
48 | features of the system. | ||
48 | \end{abstract} | 49 | \end{abstract} |
49 | 50 | ||
50 | \vspace{4ex} | 51 | \vspace{4ex} |
@@ -57,8 +58,8 @@ Lua \'e uma linguagem de extens\~ao projetada para ser usada como | |||
57 | linguagem de configura\c{c}\~ao em qualquer programa que precise de | 58 | linguagem de configura\c{c}\~ao em qualquer programa que precise de |
58 | uma. | 59 | uma. |
59 | Este documento descreve a vers\~ao \Version\ da linguagem de | 60 | Este documento descreve a vers\~ao \Version\ da linguagem de |
60 | programa\c{c}\~ao Lua e a Interface de Programa\c{c}\~ao que permite | 61 | programa\c{c}\~ao Lua e a Interface de Programa\c{c}\~ao (API) que permite |
61 | a intera\c{c}\~ao entre programas Lua e o programa C hospedeiro. | 62 | a intera\c{c}\~ao entre programas Lua e programas C hospedeiros. |
62 | O documento tamb\'em apresenta alguns exemplos de uso das principais | 63 | O documento tamb\'em apresenta alguns exemplos de uso das principais |
63 | ca\-racte\-r\'{\i}sticas do sistema. | 64 | ca\-racte\-r\'{\i}sticas do sistema. |
64 | \end{quotation} | 65 | \end{quotation} |
@@ -69,7 +70,7 @@ ca\-racte\-r\'{\i}sticas do sistema. | |||
69 | Lua is an extension programming language designed to support | 70 | Lua is an extension programming language designed to support |
70 | general procedural programming features with data description | 71 | general procedural programming features with data description |
71 | facilities. | 72 | facilities. |
72 | It is supposed to be used as a configuration language for any | 73 | It is intended to be used as a configuration language for any |
73 | program that needs one. | 74 | program that needs one. |
74 | %Its main extensions are related to object-oriented facilities, | 75 | %Its main extensions are related to object-oriented facilities, |
75 | %and fallbacks, | 76 | %and fallbacks, |
@@ -88,16 +89,13 @@ Through the use of C functions, Lua can be augmented to cope with | |||
88 | rather different domains, | 89 | rather different domains, |
89 | thus creating customized programming languages sharing a syntactical framework. | 90 | thus creating customized programming languages sharing a syntactical framework. |
90 | 91 | ||
91 | Lua is free distribution software, | 92 | Lua is free-distribution software, |
92 | and provided as usual with no guarantees. | 93 | and provided as usual with no guarantees. |
93 | The implementation described in this manual is available | 94 | The implementation described in this manual is available |
94 | by anonymous ftp from | 95 | at the following URL's: |
95 | \begin{verbatim} | ||
96 | ftp.icad.puc-rio.br:/pub/lua/lua.tar.gz | ||
97 | \end{verbatim} | ||
98 | or by WWW (World Wide Web) from | ||
99 | \begin{verbatim} | 96 | \begin{verbatim} |
100 | http://www.inf.puc-rio.br/~roberto/lua.html | 97 | http://www.inf.puc-rio.br/~roberto/lua.html |
98 | ftp://ftp.icad.puc-rio.br/pub/lua/lua.tar.gz | ||
101 | \end{verbatim} | 99 | \end{verbatim} |
102 | 100 | ||
103 | 101 | ||
@@ -115,14 +113,15 @@ using functions in the library that implements Lua. | |||
115 | 113 | ||
116 | \Index{Global variables} do not need declaration. | 114 | \Index{Global variables} do not need declaration. |
117 | Any variable is assumed to be global unless explicitly declared local | 115 | Any variable is assumed to be global unless explicitly declared local |
118 | (see local declarations, Section~\ref{localvar}). | 116 | (\see{localvar}). |
119 | Before the first assignment, the value of a global variable is \nil. | 117 | Before the first assignment, the value of a global variable is \nil. |
120 | 118 | ||
121 | The unit of execution of Lua is called a \Def{chunk}. | 119 | The unit of execution of Lua is called a \Def{chunk}. |
122 | The syntax for chunks is:% | 120 | The syntax% |
123 | \footnote{As usual, \rep{{\em a}} means 0 or more {\em a\/}'s, | 121 | \footnote{As usual, \rep{{\em a}} means 0 or more {\em a\/}'s, |
124 | \opt{{\em a}} means an optional {\em a} and \oneormore{{\em a}} means | 122 | \opt{{\em a}} means an optional {\em a} and \oneormore{{\em a}} means |
125 | one or more {\em a\/}'s.} | 123 | one or more {\em a\/}'s.} |
124 | for chunks is: | ||
126 | \begin{Produc} | 125 | \begin{Produc} |
127 | \produc{chunk}{\rep{statement \Or function}} | 126 | \produc{chunk}{\rep{statement \Or function}} |
128 | \end{Produc}% | 127 | \end{Produc}% |
@@ -138,7 +137,7 @@ of new functions% | |||
138 | assignment to a global variable; \see{TypesSec}.}. | 137 | assignment to a global variable; \see{TypesSec}.}. |
139 | 138 | ||
140 | Chunks may be pre-compiled; see program \IndexVerb{luac} for details. | 139 | Chunks may be pre-compiled; see program \IndexVerb{luac} for details. |
141 | Ascii files with chunk code and their binary pre-compiled forms | 140 | Text files with chunks and their binary pre-compiled forms |
142 | are interchangeable. | 141 | are interchangeable. |
143 | Lua automatically detects the file type and acts accordingly. | 142 | Lua automatically detects the file type and acts accordingly. |
144 | \index{pre-compilation} | 143 | \index{pre-compilation} |
@@ -174,7 +173,7 @@ However, by using fallbacks, the programmer may define operations | |||
174 | for {\em userdata} values; \see{fallback}. | 173 | for {\em userdata} values; \see{fallback}. |
175 | 174 | ||
176 | The type {\em table} implements \Index{associative arrays}, | 175 | The type {\em table} implements \Index{associative arrays}, |
177 | that is, \Index{arrays} which can be indexed not only with numbers, | 176 | that is, \Index{arrays} that can be indexed not only with numbers, |
178 | but with any value (except \nil). | 177 | but with any value (except \nil). |
179 | Therefore, this type may be used not only to represent ordinary arrays, | 178 | Therefore, this type may be used not only to represent ordinary arrays, |
180 | but also symbol tables, sets, records, etc. | 179 | but also symbol tables, sets, records, etc. |
@@ -192,14 +191,14 @@ It is important to notice that tables are objects, and not values. | |||
192 | Variables cannot contain tables, only references to them. | 191 | Variables cannot contain tables, only references to them. |
193 | Assignment, parameter passing and returns always manipulate references | 192 | Assignment, parameter passing and returns always manipulate references |
194 | to tables, and do not imply any kind of copy. | 193 | to tables, and do not imply any kind of copy. |
195 | Moreover, tables must be explicitly created before used; | 194 | Moreover, tables must be explicitly created before used |
196 | \see{tableconstructor}. | 195 | (\see{tableconstructor}). |
197 | 196 | ||
198 | 197 | ||
199 | 198 | ||
200 | \section{The Language} | 199 | \section{The Language} |
201 | 200 | ||
202 | This section describes the lexis, syntax and semantics of Lua. | 201 | This section describes the lexis, the syntax and the semantics of Lua. |
203 | 202 | ||
204 | 203 | ||
205 | \subsection{Lexical Conventions} \label{lexical} | 204 | \subsection{Lexical Conventions} \label{lexical} |
@@ -210,9 +209,10 @@ not beginning with a digit. | |||
210 | The following words are reserved, and cannot be used as identifiers: | 209 | The following words are reserved, and cannot be used as identifiers: |
211 | \index{reserved words} | 210 | \index{reserved words} |
212 | \begin{verbatim} | 211 | \begin{verbatim} |
213 | and do else elseif end | 212 | and do else elseif |
214 | function if local nil not | 213 | end function if local |
215 | or repeat return until then while | 214 | nil not or repeat |
215 | return then until while | ||
216 | \end{verbatim} | 216 | \end{verbatim} |
217 | 217 | ||
218 | The following strings denote other \Index{tokens}: | 218 | The following strings denote other \Index{tokens}: |
@@ -225,8 +225,8 @@ The following strings denote other \Index{tokens}: | |||
225 | and can contain the C-like escape sequences | 225 | and can contain the C-like escape sequences |
226 | \verb-'\n'-, \verb-'\t'- and \verb-'\r'-. | 226 | \verb-'\n'-, \verb-'\t'- and \verb-'\r'-. |
227 | Literal strings can also be delimited by matching \verb'[[ ... ]]'. | 227 | Literal strings can also be delimited by matching \verb'[[ ... ]]'. |
228 | Literals in this last form may run for several lines, | 228 | Literals in this bracketed form may run for several lines, |
229 | may contain nested \verb'[[ ... ]]', | 229 | may contain nested \verb'[[ ... ]]' pairs, |
230 | and do not interpret escape sequences. | 230 | and do not interpret escape sequences. |
231 | 231 | ||
232 | \Index{Comments} start anywhere outside a string with a | 232 | \Index{Comments} start anywhere outside a string with a |
@@ -248,8 +248,9 @@ that string to a number, following the usual rules. | |||
248 | Conversely, whenever a number is used when a string is expected, | 248 | Conversely, whenever a number is used when a string is expected, |
249 | that number is converted to a string, according to the following rule: | 249 | that number is converted to a string, according to the following rule: |
250 | if the number is an integer, it is written without exponent or decimal point; | 250 | if the number is an integer, it is written without exponent or decimal point; |
251 | otherwise, it is formatted following the ``\verb'%g''' | 251 | otherwise, it is formatted following the \verb'%g' |
252 | conversion specification of the standard \verb'printf' C function. | 252 | conversion specification of the \verb'printf' function in the |
253 | standard C library. | ||
253 | 254 | ||
254 | 255 | ||
255 | 256 | ||
@@ -261,8 +262,8 @@ the system does not know how many values a function will return, | |||
261 | or how many parameters it needs. | 262 | or how many parameters it needs. |
262 | Therefore, sometimes, a list of values must be {\em adjusted\/}, at run time, | 263 | Therefore, sometimes, a list of values must be {\em adjusted\/}, at run time, |
263 | to a given length. | 264 | to a given length. |
264 | If there are more values than are needed, the last values are thrown away. | 265 | If there are more values than are needed, then the last values are thrown away. |
265 | If there are more needs than values, the list is extended with as | 266 | If there are more needs than values, then the list is extended with as |
266 | many \nil's as needed. | 267 | many \nil's as needed. |
267 | Adjustment occurs in multiple assignment and function calls. | 268 | Adjustment occurs in multiple assignment and function calls. |
268 | 269 | ||
@@ -272,18 +273,18 @@ Adjustment occurs in multiple assignment and function calls. | |||
272 | Lua supports an almost conventional set of \Index{statements}. | 273 | Lua supports an almost conventional set of \Index{statements}. |
273 | The conventional commands include | 274 | The conventional commands include |
274 | assignment, control structures and procedure calls. | 275 | assignment, control structures and procedure calls. |
275 | Non-conventional commands include table constructors, | 276 | Non-conventional commands include table constructors |
276 | explained in Section \ref{tableconstructor}, | 277 | (Section~\ref{tableconstructor}), |
277 | and local variable declarations. | 278 | and local variable declarations (Section~\ref{localvar}). |
278 | 279 | ||
279 | \subsubsection{Blocks} | 280 | \subsubsection{Blocks} |
280 | A \Index{block} is a list of statements, executed sequentially. | 281 | A \Index{block} is a list of statements, which is executed sequentially. |
281 | Any statement can be optionally followed by a semicolon. | 282 | Any statement can be optionally followed by a semicolon: |
282 | \begin{Produc} | 283 | \begin{Produc} |
283 | \produc{block}{\rep{stat sc} \opt{ret sc}} | 284 | \produc{block}{\rep{stat sc} \opt{ret sc}} |
284 | \produc{sc}{\opt{\ter{;}}} | 285 | \produc{sc}{\opt{\ter{;}}} |
285 | \end{Produc}% | 286 | \end{Produc}% |
286 | For syntactic reasons, a \Index{return statement} can only be written | 287 | For syntactic reasons, a \IndexVerb{return} statement can only be written |
287 | as the last statement of a block. | 288 | as the last statement of a block. |
288 | This restriction also avoids some ``statement not reached'' errors. | 289 | This restriction also avoids some ``statement not reached'' errors. |
289 | 290 | ||
@@ -291,7 +292,7 @@ This restriction also avoids some ``statement not reached'' errors. | |||
291 | The language allows \Index{multiple assignment}. | 292 | The language allows \Index{multiple assignment}. |
292 | Therefore, the syntax defines a list of variables on the left side, | 293 | Therefore, the syntax defines a list of variables on the left side, |
293 | and a list of expressions on the right side. | 294 | and a list of expressions on the right side. |
294 | Both lists have their elements separated by commas. | 295 | Both lists have their elements separated by commas: |
295 | \begin{Produc} | 296 | \begin{Produc} |
296 | \produc{stat}{varlist1 \ter{=} explist1} | 297 | \produc{stat}{varlist1 \ter{=} explist1} |
297 | \produc{varlist1}{var \rep{\ter{,} var}} | 298 | \produc{varlist1}{var \rep{\ter{,} var}} |
@@ -304,33 +305,34 @@ Therefore, it can be used to exchange two values, as in | |||
304 | x, y = y, x | 305 | x, y = y, x |
305 | \end{verbatim} | 306 | \end{verbatim} |
306 | Before the assignment, the list of values is {\em adjusted} to | 307 | Before the assignment, the list of values is {\em adjusted} to |
307 | the length of the list of variables; \see{adjust}. | 308 | the length of the list of variables (\see{adjust}). |
308 | 309 | ||
310 | A single name can denote a global or a local variable, | ||
311 | or a formal parameter: | ||
309 | \begin{Produc} | 312 | \begin{Produc} |
310 | \produc{var}{name} | 313 | \produc{var}{name} |
311 | \end{Produc}% | 314 | \end{Produc}% |
312 | A single name can denote a global or a local variable, | 315 | Square brackets are used to index a table: |
313 | or a formal parameter. | ||
314 | \begin{Produc} | 316 | \begin{Produc} |
315 | \produc{var}{var \ter{[} exp1 \ter{]}} | 317 | \produc{var}{var \ter{[} exp1 \ter{]}} |
316 | \end{Produc}% | 318 | \end{Produc}% |
317 | Square brackets are used to index a table. | ||
318 | If \verb'var' results in a table value, | 319 | If \verb'var' results in a table value, |
319 | the field indexed by the expression value gets the assigned value. | 320 | the field indexed by the expression value gets the assigned value. |
320 | Otherwise, the fallback {\em settable} is called, | 321 | Otherwise, the fallback {\em settable} is called, |
321 | with three parameters: the value of \verb'var', | 322 | with three parameters: the value of \verb'var', |
322 | the value of expression, and the value being assigned to it; | 323 | the value of expression, and the value being assigned to it; |
323 | \see{fallback}. | 324 | \see{fallback}. |
325 | |||
326 | The syntax \verb'var.NAME' is just syntactic sugar for | ||
327 | \verb'var["NAME"]'. | ||
324 | \begin{Produc} | 328 | \begin{Produc} |
325 | \produc{var}{var \ter{.} name} | 329 | \produc{var}{var \ter{.} name} |
326 | \end{Produc}% | 330 | \end{Produc}% |
327 | The syntax \verb'var.NAME' is just syntactic sugar for | ||
328 | \verb'var["NAME"]'. | ||
329 | 331 | ||
330 | \subsubsection{Control Structures} | 332 | \subsubsection{Control Structures} |
331 | The \Index{condition expression} of a control structure can return any value. | 333 | The \Index{condition expression} of a control structure can return any value. |
332 | All values different from \nil\ are considered true, | 334 | All values different from \nil\ are considered true; |
333 | while \nil\ is considered false. | 335 | \nil\ is considered false. |
334 | {\tt if}'s, {\tt while}'s and {\tt repeat}'s have the usual meaning. | 336 | {\tt if}'s, {\tt while}'s and {\tt repeat}'s have the usual meaning. |
335 | 337 | ||
336 | \index{while-do}\index{repeat-until}\index{if-then-else} | 338 | \index{while-do}\index{repeat-until}\index{if-then-else} |
@@ -351,7 +353,7 @@ the syntax for a \Index{return statement} is: | |||
351 | 353 | ||
352 | \subsubsection{Function Calls as Statements} \label{funcstat} | 354 | \subsubsection{Function Calls as Statements} \label{funcstat} |
353 | Because of possible side-effects, | 355 | Because of possible side-effects, |
354 | function calls can be executed as statements. | 356 | function calls can be executed as statements: |
355 | \begin{Produc} | 357 | \begin{Produc} |
356 | \produc{stat}{functioncall} | 358 | \produc{stat}{functioncall} |
357 | \end{Produc}% | 359 | \end{Produc}% |
@@ -368,7 +370,7 @@ The declaration may include an initial assignment: | |||
368 | \produc{declist}{name \rep{\ter{,} name}} | 370 | \produc{declist}{name \rep{\ter{,} name}} |
369 | \produc{init}{\ter{=} explist1} | 371 | \produc{init}{\ter{=} explist1} |
370 | \end{Produc}% | 372 | \end{Produc}% |
371 | If there is an initial assignment, it has the same semantics | 373 | If present, an initial assignment has the same semantics |
372 | of a multiple assignment. | 374 | of a multiple assignment. |
373 | Otherwise, all variables are initialized with \nil. | 375 | Otherwise, all variables are initialized with \nil. |
374 | 376 | ||
@@ -395,23 +397,23 @@ These operators are the binary | |||
395 | and the unary \verb'-'. | 397 | and the unary \verb'-'. |
396 | If the operands are numbers, or strings that can be converted to | 398 | If the operands are numbers, or strings that can be converted to |
397 | numbers, according to the rules given in Section \ref{coercion}, | 399 | numbers, according to the rules given in Section \ref{coercion}, |
398 | all operations but exponentiation have the usual meaning. | 400 | then all operations but exponentiation have the usual meaning. |
399 | Otherwise, the fallback ``arith'' is called; \see{fallback}. | 401 | Otherwise, the fallback ``arith'' is called (\see{fallback}). |
400 | An exponentiation always calls this fallback. | 402 | An exponentiation always calls this fallback. |
401 | The standard mathematical library redefines this fallback, | 403 | The standard mathematical library redefines this fallback, |
402 | giving the expected meaning to \Index{exponentiation}; | 404 | giving the expected meaning to \Index{exponentiation} |
403 | \see{mathlib}. | 405 | (\see{mathlib}). |
404 | 406 | ||
405 | \subsubsection{Relational Operators} | 407 | \subsubsection{Relational Operators} |
406 | Lua offers the following \Index{relational operators}: | 408 | Lua provides the following \Index{relational operators}: |
407 | \begin{verbatim} | 409 | \begin{verbatim} |
408 | < > <= >= ~= == | 410 | < > <= >= ~= == |
409 | \end{verbatim} | 411 | \end{verbatim} |
410 | All return \nil\ as false and a value different from \nil\ | 412 | All these return \nil\ as false and a value different from \nil\ |
411 | (actually the number 1) as true. | 413 | (actually the number 1) as true. |
412 | 414 | ||
413 | Equality first compares the types of its operands. | 415 | Equality first compares the types of its operands. |
414 | If they are different, the result is \nil. | 416 | If they are different, then the result is \nil. |
415 | Otherwise, their values are compared. | 417 | Otherwise, their values are compared. |
416 | Numbers and strings are compared in the usual way. | 418 | Numbers and strings are compared in the usual way. |
417 | Tables, CFunctions, and functions are compared by reference, | 419 | Tables, CFunctions, and functions are compared by reference, |
@@ -419,13 +421,13 @@ that is, two tables are considered equal only if they are the same table. | |||
419 | The operator \verb'~=' is exactly the negation of equality (\verb'=='). | 421 | The operator \verb'~=' is exactly the negation of equality (\verb'=='). |
420 | 422 | ||
421 | The other operators work as follows. | 423 | The other operators work as follows. |
422 | If both arguments are numbers, they are compared as such. | 424 | If both arguments are numbers, then they are compared as such. |
423 | Otherwise, if both arguments can be converted to strings, | 425 | Otherwise, if both arguments can be converted to strings, |
424 | their values are compared using lexicographical order. | 426 | their values are compared using lexicographical order. |
425 | Otherwise, the fallback ``order'' is called; \see{fallback}. | 427 | Otherwise, the ``order'' fallback is called (\see{fallback}). |
426 | 428 | ||
427 | \subsubsection{Logical Operators} | 429 | \subsubsection{Logical Operators} |
428 | All logical operators, like control structures, | 430 | Like control structures, all logical operators |
429 | consider \nil\ as false and anything else as true. | 431 | consider \nil\ as false and anything else as true. |
430 | The \Index{logical operators} are: | 432 | The \Index{logical operators} are: |
431 | \index{and}\index{or}\index{not} | 433 | \index{and}\index{or}\index{not} |
@@ -439,9 +441,9 @@ the second operand is evaluated only if necessary. | |||
439 | \subsubsection{Concatenation} | 441 | \subsubsection{Concatenation} |
440 | Lua offers a string \Index{concatenation} operator, | 442 | Lua offers a string \Index{concatenation} operator, |
441 | denoted by ``\IndexVerb{..}''. | 443 | denoted by ``\IndexVerb{..}''. |
442 | If operands are strings or numbers, they are converted to | 444 | If operands are strings or numbers, then they are converted to |
443 | strings according to the rules in Section \ref{coercion}. | 445 | strings according to the rules in Section \ref{coercion}. |
444 | Otherwise, the fallback ``concat'' is called; \see{fallback}. | 446 | Otherwise, the fallback ``concat'' is called (\see{fallback}). |
445 | 447 | ||
446 | \subsubsection{Precedence} | 448 | \subsubsection{Precedence} |
447 | \Index{Operator precedence} follows the table below, | 449 | \Index{Operator precedence} follows the table below, |
@@ -455,7 +457,8 @@ from the lower to the higher priority: | |||
455 | not - (unary) | 457 | not - (unary) |
456 | ^ | 458 | ^ |
457 | \end{verbatim} | 459 | \end{verbatim} |
458 | All binary operators are left associative, except for \verb'^', | 460 | All binary operators are left associative, |
461 | except for \verb'^' (exponentiation), | ||
459 | which is right associative. | 462 | which is right associative. |
460 | 463 | ||
461 | \subsubsection{Table Constructors} \label{tableconstructor} | 464 | \subsubsection{Table Constructors} \label{tableconstructor} |
@@ -478,7 +481,7 @@ The form {\em lfieldlist1} is used to initialize lists. | |||
478 | \end{Produc}% | 481 | \end{Produc}% |
479 | The expressions in the list are assigned to consecutive numerical indexes, | 482 | The expressions in the list are assigned to consecutive numerical indexes, |
480 | starting with 1. | 483 | starting with 1. |
481 | As an example: | 484 | For example: |
482 | \begin{verbatim} | 485 | \begin{verbatim} |
483 | a = {"v1", "v2", 34} | 486 | a = {"v1", "v2", 34} |
484 | \end{verbatim} | 487 | \end{verbatim} |
@@ -491,12 +494,12 @@ is equivalent to: | |||
491 | a = temp | 494 | a = temp |
492 | \end{verbatim} | 495 | \end{verbatim} |
493 | 496 | ||
494 | The next form initializes named fields in a table. | 497 | The next form initializes named fields in a table: |
495 | \begin{Produc} | 498 | \begin{Produc} |
496 | \produc{ffieldlist1}{ffield \rep{\ter{,} ffield} \opt{\ter{,}}} | 499 | \produc{ffieldlist1}{ffield \rep{\ter{,} ffield} \opt{\ter{,}}} |
497 | \produc{ffield}{name \ter{=} exp} | 500 | \produc{ffield}{name \ter{=} exp} |
498 | \end{Produc}% | 501 | \end{Produc}% |
499 | As an example: | 502 | For example: |
500 | \begin{verbatim} | 503 | \begin{verbatim} |
501 | a = {x = 1, y = 3} | 504 | a = {x = 1, y = 3} |
502 | \end{verbatim} | 505 | \end{verbatim} |
@@ -516,8 +519,8 @@ A \Index{function call} has the following syntax: | |||
516 | \end{Produc}% | 519 | \end{Produc}% |
517 | Here, \verb'var' can be any variable (global, local, indexed, etc). | 520 | Here, \verb'var' can be any variable (global, local, indexed, etc). |
518 | If its type is {\em function\/} or {\em CFunction\/}, | 521 | If its type is {\em function\/} or {\em CFunction\/}, |
519 | this function is called. | 522 | then this function is called. |
520 | Otherwise, the fallback ``function'' is called, | 523 | Otherwise, the ``function'' fallback is called, |
521 | having as first parameter the value of \verb'var', | 524 | having as first parameter the value of \verb'var', |
522 | and then the original call parameters. | 525 | and then the original call parameters. |
523 | 526 | ||
@@ -553,10 +556,10 @@ If the function is called as a statement (\see{funcstat}), | |||
553 | its return list is adjusted to 0. | 556 | its return list is adjusted to 0. |
554 | If the function is called in a place that needs a single value | 557 | If the function is called in a place that needs a single value |
555 | (syntactically denoted by the non-terminal \verb'exp1'), | 558 | (syntactically denoted by the non-terminal \verb'exp1'), |
556 | its return list is adjusted to 1. | 559 | then its return list is adjusted to 1. |
557 | If the function is called in a place that can hold many values | 560 | If the function is called in a place that can hold many values |
558 | (syntactically denoted by the non-terminal \verb'exp'), | 561 | (syntactically denoted by the non-terminal \verb'exp'), |
559 | no adjustment is done. | 562 | then no adjustment is made. |
560 | 563 | ||
561 | 564 | ||
562 | \subsection{\Index{Function Definitions}} | 565 | \subsection{\Index{Function Definitions}} |
@@ -582,15 +585,15 @@ initialized with the argument values. | |||
582 | 585 | ||
583 | Results are returned using the \verb'return' statement (\see{return}). | 586 | Results are returned using the \verb'return' statement (\see{return}). |
584 | If control reaches the end of a function without a return instruction, | 587 | If control reaches the end of a function without a return instruction, |
585 | the function returns with no results. | 588 | then the function returns with no results. |
586 | 589 | ||
587 | There is a special syntax for definition of \Index{methods}, | 590 | There is a special syntax for defining \Index{methods}, |
588 | that is, functions which have an extra parameter \Def{self}. | 591 | that is, functions that have an extra parameter \Def{self}. |
589 | \begin{Produc} | 592 | \begin{Produc} |
590 | \produc{function}{\rwd{function} var \ter{:} name \ter{(} \opt{parlist1} | 593 | \produc{function}{\rwd{function} var \ter{:} name \ter{(} \opt{parlist1} |
591 | \ter{)} block \rwd{end}} | 594 | \ter{)} block \rwd{end}} |
592 | \end{Produc}% | 595 | \end{Produc}% |
593 | A declaration like | 596 | Thus, a declaration like |
594 | \begin{verbatim} | 597 | \begin{verbatim} |
595 | function v:f (...) | 598 | function v:f (...) |
596 | ... | 599 | ... |
@@ -611,13 +614,13 @@ the variable \verb'v' must have been previously initialized with a table value. | |||
611 | 614 | ||
612 | Lua provides a powerful mechanism to extend its semantics, | 615 | Lua provides a powerful mechanism to extend its semantics, |
613 | called \Def{fallbacks}. | 616 | called \Def{fallbacks}. |
614 | Basically, a fallback is a programmer defined function | 617 | A fallback is a programmer defined function |
615 | which is called whenever Lua does not know how to proceed. | 618 | that is called whenever Lua does not know how to proceed. |
616 | 619 | ||
617 | Lua supports the following fallbacks, | 620 | Lua supports the following fallbacks, |
618 | identified by the given strings: | 621 | identified by the given strings: |
619 | \begin{description} | 622 | \begin{description} |
620 | \item[``arith'']\index{arithmetic fallback} | 623 | \item[``arith'':]\index{arithmetic fallback} |
621 | called when an arithmetic operation is applied to non numerical operands, | 624 | called when an arithmetic operation is applied to non numerical operands, |
622 | or when the binary \verb'^' operation is called. | 625 | or when the binary \verb'^' operation is called. |
623 | It receives three arguments: | 626 | It receives three arguments: |
@@ -628,7 +631,7 @@ and one of the following strings describing the offended operator: | |||
628 | \end{verbatim} | 631 | \end{verbatim} |
629 | Its return value is the final result of the arithmetic operation. | 632 | Its return value is the final result of the arithmetic operation. |
630 | The default function issues an error. | 633 | The default function issues an error. |
631 | \item[``order'']\index{order fallback} | 634 | \item[``order'':]\index{order fallback} |
632 | called when an order comparison is applied to non numerical or | 635 | called when an order comparison is applied to non numerical or |
633 | non string operands. | 636 | non string operands. |
634 | It receives three arguments: | 637 | It receives three arguments: |
@@ -639,40 +642,40 @@ one of the following strings describing the offended operator: | |||
639 | \end{verbatim} | 642 | \end{verbatim} |
640 | Its return value is the final result of the comparison operation. | 643 | Its return value is the final result of the comparison operation. |
641 | The default function issues an error. | 644 | The default function issues an error. |
642 | \item[``concat'']\index{concatenation fallback} | 645 | \item[``concat'':]\index{concatenation fallback} |
643 | called when a concatenation is applied to non string operands. | 646 | called when a concatenation is applied to non string operands. |
644 | It receives the two operands as arguments. | 647 | It receives the two operands as arguments. |
645 | Its return value is the final result of the concatenation operation. | 648 | Its return value is the final result of the concatenation operation. |
646 | The default function issues an error. | 649 | The default function issues an error. |
647 | \item[``index'']\index{index fallback} | 650 | \item[``index'':]\index{index fallback} |
648 | called when Lua tries to retrieve the value of an index | 651 | called when Lua tries to retrieve the value of an index |
649 | not present in a table. | 652 | not present in a table. |
650 | It receives as arguments the table and the index. | 653 | It receives as arguments the table and the index. |
651 | Its return value is the final result of the indexing operation. | 654 | Its return value is the final result of the indexing operation. |
652 | The default function returns nil. | 655 | The default function returns nil. |
653 | \item[``getglobal'']\index{index getglobal} | 656 | \item[``getglobal'':]\index{index getglobal} |
654 | called when Lua tries to retrieve the value of a global variable | 657 | called when Lua tries to retrieve the value of a global variable |
655 | which has a nil value (or which has not been initialized). | 658 | which has a nil value (or which has not been initialized). |
656 | It receives as argument the name of the variable. | 659 | It receives as argument the name of the variable. |
657 | Its return value is the final result of the expression. | 660 | Its return value is the final result of the expression. |
658 | The default function returns nil. | 661 | The default function returns nil. |
659 | \item[``gettable'']\index{gettable fallback} | 662 | \item[``gettable'':]\index{gettable fallback} |
660 | called when Lua tries to index a non table value. | 663 | called when Lua tries to index a non table value. |
661 | It receives as arguments the non table value and the index. | 664 | It receives as arguments the non table value and the index. |
662 | Its return value is the final result of the indexing operation. | 665 | Its return value is the final result of the indexing operation. |
663 | The default function issues an error. | 666 | The default function issues an error. |
664 | \item[``settable'']\index{settable fallback} | 667 | \item[``settable'':]\index{settable fallback} |
665 | called when Lua tries to assign indexed a non table value. | 668 | called when Lua tries to assign indexed a non table value. |
666 | It receives as arguments the non table value, | 669 | It receives as arguments the non table value, |
667 | the index, and the assigned value. | 670 | the index, and the assigned value. |
668 | The default function issues an error. | 671 | The default function issues an error. |
669 | \item[``function'']\index{function falback} | 672 | \item[``function'':]\index{function falback} |
670 | called when Lua tries to call a non function value. | 673 | called when Lua tries to call a non function value. |
671 | It receives as arguments the non function value and the | 674 | It receives as arguments the non function value and the |
672 | arguments given in the original call. | 675 | arguments given in the original call. |
673 | Its return values are the final results of the call operation. | 676 | Its return values are the final results of the call operation. |
674 | The default function issues an error. | 677 | The default function issues an error. |
675 | \item[``gc''] | 678 | \item[``gc'':] |
676 | called during garbage collection. | 679 | called during garbage collection. |
677 | It receives as argument the table being collected. | 680 | It receives as argument the table being collected. |
678 | After each run of the collector this function is called with argument nil. | 681 | After each run of the collector this function is called with argument nil. |
@@ -681,15 +684,15 @@ it must be used with great care, | |||
681 | and programmers should avoid the creation of new objects | 684 | and programmers should avoid the creation of new objects |
682 | (tables or strings) in this function. | 685 | (tables or strings) in this function. |
683 | The default function does nothing. | 686 | The default function does nothing. |
684 | \item[``error'']\index{error fallback} | 687 | \item[``error'':]\index{error fallback} |
685 | called when an error occurs. | 688 | called when an error occurs. |
686 | It receives as argument a string describing the error. | 689 | It receives as argument a string describing the error. |
687 | The default function prints the message on the standard error output. | 690 | The default function prints the message on the standard error output. |
688 | \end{description} | 691 | \end{description} |
689 | 692 | ||
690 | The function \IndexVerb{setfallback} is used to change a fallback action. | 693 | The function \IndexVerb{setfallback} is used to change a fallback function. |
691 | Its first argument is a string describing the fallback, | 694 | Its first argument is the name of a fallback condition, |
692 | and the second the new function to be called. | 695 | and the second argument is the new function to be called. |
693 | It returns the old function for the given fallback. | 696 | It returns the old function for the given fallback. |
694 | 697 | ||
695 | Section \ref{exfallback} shows an example of the use of fallbacks. | 698 | Section \ref{exfallback} shows an example of the use of fallbacks. |
@@ -700,18 +703,18 @@ Section \ref{exfallback} shows an example of the use of fallbacks. | |||
700 | Because Lua is an extension language, | 703 | Because Lua is an extension language, |
701 | all Lua actions start from C code calling a function from the Lua library. | 704 | all Lua actions start from C code calling a function from the Lua library. |
702 | Whenever an error occurs during Lua compilation or execution, | 705 | Whenever an error occurs during Lua compilation or execution, |
703 | an error fallback function is called, | 706 | an ``error'' fallback function is called, |
704 | and then the corresponding function from the library | 707 | and then the corresponding function from the library |
705 | (\verb'lua_dofile', \verb'lua_dostring', | 708 | (\verb'lua_dofile', \verb'lua_dostring', |
706 | \verb'lua_call', and \verb'lua_callfunction') | 709 | \verb'lua_call', and \verb'lua_callfunction') |
707 | is terminated returning an error condition. | 710 | is terminated returning an error condition. |
708 | 711 | ||
709 | The only argument to the error fallback function is a string describing | 712 | The only argument to the ``error'' fallback function is a string |
710 | the error. | 713 | describing the error. |
711 | The standard I/O library redefines this fallback, | 714 | The standard I/O library redefines this fallback, |
712 | using the debug facilities (\see{debugI}, | 715 | using the debug facilities (\see{debugI}), |
713 | in order to print some extra informations, | 716 | in order to print some extra information, |
714 | like the stack of calls. | 717 | like the call stack. |
715 | For more information about an error, | 718 | For more information about an error, |
716 | the Lua program can include the compilation pragma \verb'$debug'. | 719 | the Lua program can include the compilation pragma \verb'$debug'. |
717 | \index{debug pragma}\label{pragma} | 720 | \index{debug pragma}\label{pragma} |
@@ -719,12 +722,11 @@ This pragma must be written in a line by itself. | |||
719 | When an error occurs in a program compiled with this option, | 722 | When an error occurs in a program compiled with this option, |
720 | the error routine is able to print also the lines where the calls | 723 | the error routine is able to print also the lines where the calls |
721 | (and the error) were made. | 724 | (and the error) were made. |
722 | If needed, it is possible to change the error fallback routine; | 725 | If needed, it is possible to change the ``error'' fallback routine |
723 | \see{fallback}. | 726 | (\see{fallback}). |
724 | 727 | ||
725 | Lua code can generate an error by calling the function \verb'error'. | 728 | Lua code can generate an error by calling the built-in |
726 | Its optional parameter is a string, | 729 | function \verb'error' (\see{pdf-error}). |
727 | which is used as the error message. | ||
728 | 730 | ||
729 | 731 | ||
730 | \section{The Application Program Interface} | 732 | \section{The Application Program Interface} |
@@ -741,24 +743,24 @@ The API functions can be classified in the following categories: | |||
741 | \item C functions to be called by Lua; | 743 | \item C functions to be called by Lua; |
742 | \item references to Lua Objects. | 744 | \item references to Lua Objects. |
743 | \end{enumerate} | 745 | \end{enumerate} |
744 | All API functions are declared in the file \verb'lua.h'. | 746 | All API functions are declared in the header file \verb'lua.h'. |
745 | 747 | ||
746 | \subsection{Executing Lua Code} | 748 | \subsection{Executing Lua Code} |
747 | A host program can execute Lua chunks written in a file or in a string, | 749 | A host program can execute Lua chunks written in a file or in a string, |
748 | using the following functions: | 750 | using the following functions: |
749 | \Deffunc{lua_dofile}\Deffunc{lua_dostring} | 751 | \Deffunc{lua_dofile}\Deffunc{lua_dostring} |
750 | \begin{verbatim} | 752 | \begin{verbatim} |
751 | int lua_dofile (char *filename); | 753 | int lua_dofile (char *filename); |
752 | int lua_dostring (char *string); | 754 | int lua_dostring (char *string); |
753 | \end{verbatim} | 755 | \end{verbatim} |
754 | Both functions return an error code: | 756 | Both functions return an error code: |
755 | 0, in case of success; non zero, in case of errors. | 757 | 0, in case of success; non zero, in case of errors. |
756 | More specifically, \verb'lua_dofile' returns 2 if for any reason | 758 | More specifically, \verb'lua_dofile' returns 2 if for any reason |
757 | it could not open the file. | 759 | it could not open the file. |
758 | The function \verb'lua_dofile', if called with argument NULL (0), | 760 | The function \verb'lua_dofile', if called with argument \verb'NULL' (0), |
759 | executes the ``file'' {\tt stdin}. | 761 | executes the {\tt stdin} stream. |
760 | Function \verb'lua_dofile' is also able to execute pre-compiled chunks. | 762 | Function \verb'lua_dofile' is also able to execute pre-compiled chunks. |
761 | It detects whether the file is text or not, | 763 | It automatically detects whether the file is text or binary, |
762 | and loads it accordingly (see program \IndexVerb{luac}). | 764 | and loads it accordingly (see program \IndexVerb{luac}). |
763 | 765 | ||
764 | \subsection{Converting Values between C and Lua} \label{valuesCLua} | 766 | \subsection{Converting Values between C and Lua} \label{valuesCLua} |
@@ -770,8 +772,8 @@ Values of type \verb'lua_Object' have no meaning outside Lua; | |||
770 | for instance, | 772 | for instance, |
771 | the comparisson of two \verb"lua_Object's" is of no significance. | 773 | the comparisson of two \verb"lua_Object's" is of no significance. |
772 | 774 | ||
773 | Lua has automatic memory management, and garbage collection. | 775 | Because Lua has automatic memory management and garbage collection, |
774 | Because of that, a \verb'lua_Object' has a limited scope, | 776 | a \verb'lua_Object' has a limited scope, |
775 | and is only valid inside the {\em block\/} where it was created. | 777 | and is only valid inside the {\em block\/} where it was created. |
776 | A C function called from Lua is a block, | 778 | A C function called from Lua is a block, |
777 | and its parameters are valid only until its end. | 779 | and its parameters are valid only until its end. |
@@ -815,9 +817,8 @@ and 0 otherwise. | |||
815 | The function \verb'lua_isnumber' accepts numbers and numerical strings, | 817 | The function \verb'lua_isnumber' accepts numbers and numerical strings, |
816 | \verb'lua_isstring' accepts strings and numbers (\see{coercion}), | 818 | \verb'lua_isstring' accepts strings and numbers (\see{coercion}), |
817 | and \verb'lua_isfunction' accepts Lua and C functions. | 819 | and \verb'lua_isfunction' accepts Lua and C functions. |
818 | |||
819 | The function \verb'lua_type' can be used to distinguish between | 820 | The function \verb'lua_type' can be used to distinguish between |
820 | different kinds of user data; see below. | 821 | different kinds of user data. |
821 | 822 | ||
822 | To translate a value from type \verb'lua_Object' to a specific C type, | 823 | To translate a value from type \verb'lua_Object' to a specific C type, |
823 | the programmer can use: | 824 | the programmer can use: |
@@ -866,15 +867,15 @@ plus the macro: | |||
866 | void lua_pushuserdata (void *u); | 867 | void lua_pushuserdata (void *u); |
867 | \end{verbatim} | 868 | \end{verbatim} |
868 | All of them receive a C value, | 869 | All of them receive a C value, |
869 | convert it to a correspondent \verb'lua_Object', | 870 | convert it to a corresponding \verb'lua_Object', |
870 | and leave the result on the top of the Lua stack, | 871 | and leave the result on the top of the Lua stack, |
871 | where it can be assigned to a Lua variable, | 872 | where it can be assigned to a Lua variable, |
872 | passed as paramenter to a Lua function, etc (see below). \label{pushing} | 873 | passed as parameter to a Lua function, etc. \label{pushing} |
873 | 874 | ||
874 | User data can have different tags, | 875 | User data can have different tags, |
875 | whose semantics are defined by the host program. | 876 | whose semantics are defined by the host program. |
876 | Any positive integer can be used to tag a user data. | 877 | Any positive integer can be used to tag a user datum. |
877 | When a user data is retrieved, | 878 | When a user datum is retrieved, |
878 | the function \verb'lua_type' can be used to get its tag. | 879 | the function \verb'lua_type' can be used to get its tag. |
879 | 880 | ||
880 | To complete the set, | 881 | To complete the set, |
@@ -889,13 +890,13 @@ void lua_pushobject (lua_Object object); | |||
889 | 890 | ||
890 | \subsection{Manipulating Lua Objects} | 891 | \subsection{Manipulating Lua Objects} |
891 | To read the value of any global Lua variable, | 892 | To read the value of any global Lua variable, |
892 | one can use the function: | 893 | one uses the function: |
893 | \Deffunc{lua_getglobal} | 894 | \Deffunc{lua_getglobal} |
894 | \begin{verbatim} | 895 | \begin{verbatim} |
895 | lua_Object lua_getglobal (char *varname); | 896 | lua_Object lua_getglobal (char *varname); |
896 | \end{verbatim} | 897 | \end{verbatim} |
897 | As in Lua, if the value of the global is \nil, | 898 | As in Lua, if the value of the global is \nil, |
898 | the \verb'"getglobal"' fallback is called. | 899 | then the ``getglobal'' fallback is called. |
899 | 900 | ||
900 | To store a value previously pushed onto the stack in a global variable, | 901 | To store a value previously pushed onto the stack in a global variable, |
901 | there is the function: | 902 | there is the function: |
@@ -914,7 +915,7 @@ expects on the stack a table and an index, | |||
914 | and returns the contents of the table at that index. | 915 | and returns the contents of the table at that index. |
915 | As in Lua, if the first object is not a table, | 916 | As in Lua, if the first object is not a table, |
916 | or the index is not present in the table, | 917 | or the index is not present in the table, |
917 | the correspondent fallback is called. | 918 | the corresponding fallback is called. |
918 | 919 | ||
919 | %For compatibility with previous versions of the API, | 920 | %For compatibility with previous versions of the API, |
920 | %the following macros are supported: | 921 | %the following macros are supported: |
@@ -934,20 +935,20 @@ and then call the function: | |||
934 | \begin{verbatim} | 935 | \begin{verbatim} |
935 | void lua_storesubscript (void); | 936 | void lua_storesubscript (void); |
936 | \end{verbatim} | 937 | \end{verbatim} |
937 | Again, the correspondent fallback is called if needed. | 938 | Again, the corresponding fallback is called if needed. |
938 | 939 | ||
939 | Finally, the function | 940 | Finally, the function |
940 | \Deffunc{lua_createtable} | 941 | \Deffunc{lua_createtable} |
941 | \begin{verbatim} | 942 | \begin{verbatim} |
942 | lua_Object lua_createtable (void); | 943 | lua_Object lua_createtable (void); |
943 | \end{verbatim} | 944 | \end{verbatim} |
944 | creates a new table. | 945 | creates and returns a new table. |
945 | 946 | ||
946 | {\em Please Notice:\/} | 947 | {\em Please Notice:\/} |
947 | Most functions from the Lua library receive parameters through the stack. | 948 | Most functions from the Lua library receive parameters through Lua's stack. |
948 | Because other functions also use the stack, | 949 | Because other functions also use this stack, |
949 | it is important that these | 950 | it is important that these |
950 | parameters be pushed just before the correspondent call, | 951 | parameters be pushed just before the corresponding call, |
951 | without intermediate calls to the Lua library. | 952 | without intermediate calls to the Lua library. |
952 | For instance, suppose the user wants the value of \verb'a[i]'. | 953 | For instance, suppose the user wants the value of \verb'a[i]'. |
953 | A simplistic solution would be: | 954 | A simplistic solution would be: |
@@ -1064,7 +1065,7 @@ In this way, it is possible to write functions that work with | |||
1064 | a variable number of parameters. | 1065 | a variable number of parameters. |
1065 | 1066 | ||
1066 | To return values, a C function just pushes them onto the stack, | 1067 | To return values, a C function just pushes them onto the stack, |
1067 | in direct order; \see{valuesCLua}. | 1068 | in direct order (\see{valuesCLua}). |
1068 | Like a Lua function, a C function called by Lua can also return | 1069 | Like a Lua function, a C function called by Lua can also return |
1069 | many results. | 1070 | many results. |
1070 | 1071 | ||
@@ -1073,7 +1074,7 @@ Section~\ref{exCFunction} presents an example of a CFunction. | |||
1073 | 1074 | ||
1074 | \subsection{References to Lua Objects} | 1075 | \subsection{References to Lua Objects} |
1075 | 1076 | ||
1076 | As already noted, \verb'lua_Object's are volatile. | 1077 | As noted in Section~\ref{LuacallC}, \verb'lua_Object's are volatile. |
1077 | If the C code needs to keep a \verb'lua_Object' | 1078 | If the C code needs to keep a \verb'lua_Object' |
1078 | outside block boundaries, | 1079 | outside block boundaries, |
1079 | it must create a \Def{reference} to the object. | 1080 | it must create a \Def{reference} to the object. |
@@ -1087,7 +1088,7 @@ void lua_pushref (int ref); | |||
1087 | void lua_unref (int ref); | 1088 | void lua_unref (int ref); |
1088 | \end{verbatim} | 1089 | \end{verbatim} |
1089 | The function \verb'lua_ref' creates a reference | 1090 | The function \verb'lua_ref' creates a reference |
1090 | to the object which is on the top of the stack, | 1091 | to the object that is on the top of the stack, |
1091 | and returns this reference. | 1092 | and returns this reference. |
1092 | If \verb'lock' is true, the object is {\em locked}: | 1093 | If \verb'lock' is true, the object is {\em locked}: |
1093 | that means the object will not be garbage collected. | 1094 | that means the object will not be garbage collected. |
@@ -1095,9 +1096,9 @@ Notice that an unlocked reference may be garbage collected. | |||
1095 | Whenever the referenced object is needed, | 1096 | Whenever the referenced object is needed, |
1096 | a call to \verb'lua_getref' | 1097 | a call to \verb'lua_getref' |
1097 | returns a handle to it, | 1098 | returns a handle to it, |
1098 | while \verb'lua_pushref' pushes the object on the stack. | 1099 | whereas \verb'lua_pushref' pushes the object on the stack. |
1099 | If the object has been collected, | 1100 | If the object has been collected, |
1100 | \verb'lua_getref' returns \verb'LUA_NOOBJECT', | 1101 | then \verb'lua_getref' returns \verb'LUA_NOOBJECT', |
1101 | and \verb'lua_pushobject' issues an error. | 1102 | and \verb'lua_pushobject' issues an error. |
1102 | 1103 | ||
1103 | When a reference is no longer needed, | 1104 | When a reference is no longer needed, |
@@ -1112,7 +1113,7 @@ Most of them provide features that allows some degree of | |||
1112 | \Index{reflexivity} in the language. | 1113 | \Index{reflexivity} in the language. |
1113 | Some of these features cannot be simulated with the rest of the | 1114 | Some of these features cannot be simulated with the rest of the |
1114 | Language nor with the standard Lua API. | 1115 | Language nor with the standard Lua API. |
1115 | Others are just helpful interfaces to common API functions. | 1116 | Others are just convenient interfaces to common API functions. |
1116 | 1117 | ||
1117 | The libraries, on the other hand, provide useful routines | 1118 | The libraries, on the other hand, provide useful routines |
1118 | that are implemented directly through the standard API. | 1119 | that are implemented directly through the standard API. |
@@ -1134,10 +1135,10 @@ declared in \verb-lualib.h-. | |||
1134 | 1135 | ||
1135 | \subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile} | 1136 | \subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile} |
1136 | This function receives a file name, | 1137 | This function receives a file name, |
1137 | opens it and executes its contents as a Lua chunk, | 1138 | opens it, and executes its contents as a Lua chunk, |
1138 | or as pre-compiled chunks. | 1139 | or as pre-compiled chunks. |
1139 | When called without arguments, | 1140 | When called without arguments, |
1140 | it executes the contents of the standard input. | 1141 | it executes the contents of the standard input (\verb'stdin'). |
1141 | It returns 1 if there are no errors, \nil\ otherwise. | 1142 | It returns 1 if there are no errors, \nil\ otherwise. |
1142 | It issues an error when called with a non string argument. | 1143 | It issues an error when called with a non string argument. |
1143 | 1144 | ||
@@ -1168,7 +1169,7 @@ See Section \ref{exnext} for an example of the use of this function. | |||
1168 | 1169 | ||
1169 | \subsubsection*{{\tt nextvar (name)}}\Deffunc{nextvar} | 1170 | \subsubsection*{{\tt nextvar (name)}}\Deffunc{nextvar} |
1170 | This function is similar to the function \verb'next', | 1171 | This function is similar to the function \verb'next', |
1171 | but it iterates over the global variables. | 1172 | but iterates over the global variables. |
1172 | Its single argument is the name of a global variable, | 1173 | Its single argument is the name of a global variable, |
1173 | or \nil\ to get a first name. | 1174 | or \nil\ to get a first name. |
1174 | Similarly to \verb'next', it returns the name of another variable | 1175 | Similarly to \verb'next', it returns the name of another variable |
@@ -1193,7 +1194,7 @@ See Section~\ref{libio} for functions for formatted output. | |||
1193 | This function receives one argument, | 1194 | This function receives one argument, |
1194 | and tries to convert it to a number. | 1195 | and tries to convert it to a number. |
1195 | If the argument is already a number or a string convertible | 1196 | If the argument is already a number or a string convertible |
1196 | to a number (\see{coercion}), it returns that number; | 1197 | to a number (\see{coercion}), then it returns that number; |
1197 | otherwise, it returns \nil. | 1198 | otherwise, it returns \nil. |
1198 | 1199 | ||
1199 | \subsubsection*{{\tt type (v)}}\Deffunc{type} | 1200 | \subsubsection*{{\tt type (v)}}\Deffunc{type} |
@@ -1217,7 +1218,7 @@ and between C functions and Lua functions. | |||
1217 | This function issues an {\em ``assertion failed!''} error | 1218 | This function issues an {\em ``assertion failed!''} error |
1218 | when its argument is \nil. | 1219 | when its argument is \nil. |
1219 | 1220 | ||
1220 | \subsubsection*{{\tt error (message)}}\Deffunc{error} | 1221 | \subsubsection*{{\tt error (message)}}\Deffunc{error}\label{pdf-error} |
1221 | This function issues an error message and terminates | 1222 | This function issues an error message and terminates |
1222 | the last called function from the library | 1223 | the last called function from the library |
1223 | (\verb'lua_dofile', \verb'lua_dostring', \ldots). | 1224 | (\verb'lua_dofile', \verb'lua_dostring', \ldots). |
@@ -1265,9 +1266,9 @@ Returns another string, which is a substring of \verb's', | |||
1265 | starting at \verb'i' and runing until \verb'j'. | 1266 | starting at \verb'i' and runing until \verb'j'. |
1266 | If \verb'j' is absent, | 1267 | If \verb'j' is absent, |
1267 | it is assumed to be equal to the length of \verb's'. | 1268 | it is assumed to be equal to the length of \verb's'. |
1268 | Particularly, the call \verb'strsub(s,1,j)' returns a prefix of \verb's' | 1269 | In particular, the call \verb'strsub(s,1,j)' returns a prefix of \verb's' |
1269 | with length \verb'j', | 1270 | with length \verb'j', |
1270 | while the call \verb'strsub(s,i)' returns a suffix of \verb's', | 1271 | whereas the call \verb'strsub(s,i)' returns a suffix of \verb's', |
1271 | starting at \verb'i'. | 1272 | starting at \verb'i'. |
1272 | 1273 | ||
1273 | \subsubsection*{{\tt strlower (s)}}\Deffunc{strlower} | 1274 | \subsubsection*{{\tt strlower (s)}}\Deffunc{strlower} |
@@ -1282,7 +1283,7 @@ All other characters are left unchanged. | |||
1282 | 1283 | ||
1283 | \subsubsection*{{\tt ascii (s, [i])}}\Deffunc{ascii} | 1284 | \subsubsection*{{\tt ascii (s, [i])}}\Deffunc{ascii} |
1284 | Returns the ascii code of the character \verb's[i]'. | 1285 | Returns the ascii code of the character \verb's[i]'. |
1285 | If \verb'i' is absent, it is assumed to be 1. | 1286 | If \verb'i' is absent, then it is assumed to be 1. |
1286 | 1287 | ||
1287 | \subsubsection*{{\tt format (formatstring, e1, e2, \ldots)}}\Deffunc{format} | 1288 | \subsubsection*{{\tt format (formatstring, e1, e2, \ldots)}}\Deffunc{format} |
1288 | \label{format} | 1289 | \label{format} |
@@ -1290,7 +1291,7 @@ This function returns a formated version of its variable number of arguments | |||
1290 | following the description given in its first argument (which must be a string). | 1291 | following the description given in its first argument (which must be a string). |
1291 | The format string follows the same rules as the \verb'printf' family of | 1292 | The format string follows the same rules as the \verb'printf' family of |
1292 | standard C functions. | 1293 | standard C functions. |
1293 | The only differencies are that the options/modifiers | 1294 | The only differences are that the options/modifiers |
1294 | \verb'*', \verb'l', \verb'L', \verb'n', \verb'p', | 1295 | \verb'*', \verb'l', \verb'L', \verb'n', \verb'p', |
1295 | and \verb'h' are not supported, | 1296 | and \verb'h' are not supported, |
1296 | and there is an extra option, \verb'q'. | 1297 | and there is an extra option, \verb'q'. |
@@ -1303,7 +1304,7 @@ are correctly escaped when written. | |||
1303 | The options \verb'c', \verb'd', \verb'E', \verb'e', \verb'f', | 1304 | The options \verb'c', \verb'd', \verb'E', \verb'e', \verb'f', |
1304 | \verb'g' \verb'i', \verb'o', \verb'u', \verb'X', and \verb'x' all | 1305 | \verb'g' \verb'i', \verb'o', \verb'u', \verb'X', and \verb'x' all |
1305 | expect a number argument, | 1306 | expect a number argument, |
1306 | while \verb'q' and \verb's' expect a string. | 1307 | whereas \verb'q' and \verb's' expect a string. |
1307 | 1308 | ||
1308 | 1309 | ||
1309 | \subsection{Mathematical Functions} \label{mathlib} | 1310 | \subsection{Mathematical Functions} \label{mathlib} |
@@ -1325,7 +1326,7 @@ max min mod sin sqrt tan random randomseed | |||
1325 | Most of them | 1326 | Most of them |
1326 | are only interfaces to the homonymous functions in the C library, | 1327 | are only interfaces to the homonymous functions in the C library, |
1327 | except that, for the trigonometric functions, | 1328 | except that, for the trigonometric functions, |
1328 | all angles are expressed in degrees. | 1329 | all angles are expressed in degrees, not radians. |
1329 | 1330 | ||
1330 | The function \verb'max' returns the maximum | 1331 | The function \verb'max' returns the maximum |
1331 | value of its numeric arguments. | 1332 | value of its numeric arguments. |
@@ -1343,7 +1344,7 @@ $[0,1)$. | |||
1343 | 1344 | ||
1344 | \subsection{I/O Facilities} \label{libio} | 1345 | \subsection{I/O Facilities} \label{libio} |
1345 | 1346 | ||
1346 | All I/O operations in Lua are done over two {\em current} files, | 1347 | All I/O operations in Lua are done over two {\em current} files: |
1347 | one for reading and one for writing. | 1348 | one for reading and one for writing. |
1348 | Initially, the current input file is \verb'stdin', | 1349 | Initially, the current input file is \verb'stdin', |
1349 | and the current output file is \verb'stdout'. | 1350 | and the current output file is \verb'stdout'. |
@@ -1489,15 +1490,15 @@ with an optional \verb-code-, | |||
1489 | to terminate the program. | 1490 | to terminate the program. |
1490 | 1491 | ||
1491 | 1492 | ||
1492 | \section{The Debuger Interface} \label{debugI} | 1493 | \section{The Debugger Interface} \label{debugI} |
1493 | 1494 | ||
1494 | Lua has no built in debuger facilities. | 1495 | Lua has no built-in debugger facilities. |
1495 | Instead, it offers a special interface, | 1496 | Instead, it offers a special interface, |
1496 | by means of functions and {\em hooks}, | 1497 | by means of functions and {\em hooks}, |
1497 | which allows the construction of different | 1498 | which allows the construction of different |
1498 | kinds of debugers, profiles, and other tools | 1499 | kinds of debugers, profilers, and other tools |
1499 | that need ``inside'' information from the interpreter. | 1500 | that need ``inside information'' from the interpreter. |
1500 | This interface is declared in the file \verb'luadebug.h'. | 1501 | This interface is declared in the header file \verb'luadebug.h'. |
1501 | 1502 | ||
1502 | \subsection{Stack and Function Information} | 1503 | \subsection{Stack and Function Information} |
1503 | 1504 | ||
@@ -1529,9 +1530,9 @@ char *lua_getobjname (lua_Object o, char **name); | |||
1529 | \verb'lua_funcinfo' gives the file name and the line where the | 1530 | \verb'lua_funcinfo' gives the file name and the line where the |
1530 | given function has been defined. | 1531 | given function has been defined. |
1531 | If the ``function'' is in fact the main code of a chunk, | 1532 | If the ``function'' is in fact the main code of a chunk, |
1532 | \verb'linedefined' is 0. | 1533 | then \verb'linedefined' is 0. |
1533 | If the function is a C function, | 1534 | If the function is a C function, |
1534 | \verb'linedefined' is -1, and \verb'filename' is \verb'"(C)"'. | 1535 | then \verb'linedefined' is -1, and \verb'filename' is \verb'"(C)"'. |
1535 | 1536 | ||
1536 | The function \verb'lua_currentline' gives the current line where | 1537 | The function \verb'lua_currentline' gives the current line where |
1537 | a given function is executing. | 1538 | a given function is executing. |
@@ -1550,10 +1551,10 @@ function is a fallback. | |||
1550 | If so, it returns the string \verb'"fallback"', | 1551 | If so, it returns the string \verb'"fallback"', |
1551 | and \verb'name' is set to point to the fallback name. | 1552 | and \verb'name' is set to point to the fallback name. |
1552 | Otherwise, if the given function is the value of a global variable, | 1553 | Otherwise, if the given function is the value of a global variable, |
1553 | \verb'lua_getobjname' returns the string \verb'"global"', | 1554 | then \verb'lua_getobjname' returns the string \verb'"global"', |
1554 | while \verb'name' points to the variable name. | 1555 | while \verb'name' points to the variable name. |
1555 | If the given function is neither a fallback nor a global variable, | 1556 | If the given function is neither a fallback nor a global variable, |
1556 | \verb'lua_getobjname' returns the empty string, | 1557 | then \verb'lua_getobjname' returns the empty string, |
1557 | and \verb'name' is set to \verb'NULL'. | 1558 | and \verb'name' is set to \verb'NULL'. |
1558 | 1559 | ||
1559 | \subsection{Manipulating Local Variables} | 1560 | \subsection{Manipulating Local Variables} |
@@ -1579,15 +1580,15 @@ or if the activation record has no debug information, | |||
1579 | The function \verb'lua_setlocal' sets the local variable | 1580 | The function \verb'lua_setlocal' sets the local variable |
1580 | \verb'local_number' to the value previously pushed on the stack | 1581 | \verb'local_number' to the value previously pushed on the stack |
1581 | (\see{valuesCLua}). | 1582 | (\see{valuesCLua}). |
1582 | If the function succeeds it returns 1. | 1583 | If the function succeeds, then it returns 1. |
1583 | If \verb'local_number' is greater than the number | 1584 | If \verb'local_number' is greater than the number |
1584 | of active local variables, | 1585 | of active local variables, |
1585 | or if the activation record has no debug information, | 1586 | or if the activation record has no debug information, |
1586 | this function fails and returns 0. | 1587 | then this function fails and returns 0. |
1587 | 1588 | ||
1588 | \subsection{Hooks} | 1589 | \subsection{Hooks} |
1589 | 1590 | ||
1590 | The Lua interpreter offers two hooks for debug purposes: | 1591 | The Lua interpreter offers two hooks for debugging purposes: |
1591 | \begin{verbatim} | 1592 | \begin{verbatim} |
1592 | typedef void (*lua_CHFunction) (lua_Function func, char *file, int line); | 1593 | typedef void (*lua_CHFunction) (lua_Function func, char *file, int line); |
1593 | extern lua_CHFunction lua_callhook; | 1594 | extern lua_CHFunction lua_callhook; |
@@ -1631,7 +1632,7 @@ like ordinary arrays, records, sets, bags, and lists. | |||
1631 | Arrays need no explanations. | 1632 | Arrays need no explanations. |
1632 | In Lua, it is conventional to start indices from 1, | 1633 | In Lua, it is conventional to start indices from 1, |
1633 | but this is only a convention. | 1634 | but this is only a convention. |
1634 | Arrays can be indexed by 0, negative numbers, or any other value (but \nil). | 1635 | Arrays can be indexed by 0, negative numbers, or any other value (except \nil). |
1635 | Records are also trivially implemented by the syntactic sugar | 1636 | Records are also trivially implemented by the syntactic sugar |
1636 | \verb'a.x'. | 1637 | \verb'a.x'. |
1637 | 1638 | ||
@@ -1642,15 +1643,14 @@ The statement \verb's[x] = 1' inserts the value of \verb'x' into | |||
1642 | the set \verb's'. | 1643 | the set \verb's'. |
1643 | The expression \verb's[x]' is true if and only if | 1644 | The expression \verb's[x]' is true if and only if |
1644 | \verb'x' belongs to \verb's'. | 1645 | \verb'x' belongs to \verb's'. |
1645 | Finally, the statement \verb's[x] = nil' erases \verb'x' from \verb's'. | 1646 | Finally, the statement \verb's[x] = nil' removes \verb'x' from \verb's'. |
1646 | 1647 | ||
1647 | Bags can be implemented similarly to sets, | 1648 | Bags can be implemented similarly to sets, |
1648 | but using the value associated to an element as its counter. | 1649 | but using the value associated to an element as its counter. |
1649 | So, to insert an element, | 1650 | So, to insert an element, |
1650 | the following code is enough: | 1651 | the following code is enough: |
1651 | \begin{verbatim} | 1652 | \begin{verbatim} |
1652 | if s[x] then s[x] = s[x]+1 | 1653 | if s[x] then s[x] = s[x]+1 else s[x] = 1 end |
1653 | else s[x] = 1 end | ||
1654 | \end{verbatim} | 1654 | \end{verbatim} |
1655 | and to remove an element: | 1655 | and to remove an element: |
1656 | \begin{verbatim} | 1656 | \begin{verbatim} |
@@ -1671,7 +1671,7 @@ the tail with \verb'l[2]'. | |||
1671 | \Deffunc{next}\Deffunc{nextvar} | 1671 | \Deffunc{next}\Deffunc{nextvar} |
1672 | This example shows how to use the function \verb'next' to iterate | 1672 | This example shows how to use the function \verb'next' to iterate |
1673 | over the fields of a table. | 1673 | over the fields of a table. |
1674 | Function \Def{clone} receives any table and returns a clone of it. | 1674 | Function \IndexVerb{clone} receives any table and returns a clone of it. |
1675 | \begin{verbatim} | 1675 | \begin{verbatim} |
1676 | function clone (t) -- t is a table | 1676 | function clone (t) -- t is a table |
1677 | local new_t = {} -- create a new table | 1677 | local new_t = {} -- create a new table |
@@ -1731,7 +1731,7 @@ end | |||
1731 | 1731 | ||
1732 | \subsection{\Index{Variable number of arguments}} | 1732 | \subsection{\Index{Variable number of arguments}} |
1733 | Lua does not provide any explicit mechanism to deal with | 1733 | Lua does not provide any explicit mechanism to deal with |
1734 | variable number of arguments. | 1734 | variable number of arguments in function calls. |
1735 | However, one can use table constructors to simulate this mechanism. | 1735 | However, one can use table constructors to simulate this mechanism. |
1736 | As an example, suppose a function to concatenate all its arguments. | 1736 | As an example, suppose a function to concatenate all its arguments. |
1737 | It could be written like | 1737 | It could be written like |
@@ -1778,9 +1778,9 @@ In order to restore this value, a \verb'lua_dofile' suffices. | |||
1778 | 1778 | ||
1779 | Storing tables is a little more complex. | 1779 | Storing tables is a little more complex. |
1780 | Assuming that the table is a tree, | 1780 | Assuming that the table is a tree, |
1781 | and all indices are identifiers | 1781 | and that all indices are identifiers |
1782 | (that is, the tables are being used as records), | 1782 | (that is, the tables are being used as records), |
1783 | its value can be written directly with table constructors. | 1783 | then its value can be written directly with table constructors. |
1784 | First, the function \verb'write_value' is changed to | 1784 | First, the function \verb'write_value' is changed to |
1785 | \begin{verbatim} | 1785 | \begin{verbatim} |
1786 | function write_value (value) | 1786 | function write_value (value) |
@@ -1902,9 +1902,9 @@ with the index fallback redefined according to | |||
1902 | Section~\ref{exfallback}}. | 1902 | Section~\ref{exfallback}}. |
1903 | 1903 | ||
1904 | As one could expect, a good way to represent a class is | 1904 | As one could expect, a good way to represent a class is |
1905 | as a table. | 1905 | with a table. |
1906 | This table will contain all instance methods of the class, | 1906 | This table will contain all instance methods of the class, |
1907 | plus eventual default values for instance variables. | 1907 | plus optional default values for instance variables. |
1908 | An instance of a class has its \verb'parent' field pointing to | 1908 | An instance of a class has its \verb'parent' field pointing to |
1909 | the class, | 1909 | the class, |
1910 | and so it ``inherits'' all methods. | 1910 | and so it ``inherits'' all methods. |
@@ -1942,7 +1942,7 @@ p2 = Point:create{x = 10} -- y will be inherited until it is set | |||
1942 | -- | 1942 | -- |
1943 | p1:move(p2) | 1943 | p1:move(p2) |
1944 | \end{verbatim} | 1944 | \end{verbatim} |
1945 | \caption{A Class Point.\label{Point}} | 1945 | \caption{A Class {\tt Point}.\label{Point}} |
1946 | \Line | 1946 | \Line |
1947 | \end{figure} | 1947 | \end{figure} |
1948 | Finally, a subclass can be created as a new table, | 1948 | Finally, a subclass can be created as a new table, |
@@ -2071,7 +2071,7 @@ Lua means {\em moon} in Portuguese. | |||
2071 | 2071 | ||
2072 | \appendix | 2072 | \appendix |
2073 | 2073 | ||
2074 | \section{Incompatibilities with Previous Versions} | 2074 | \section*{Incompatibilities with Previous Versions} |
2075 | 2075 | ||
2076 | Although great care has been taken to avoid incompatibilities with | 2076 | Although great care has been taken to avoid incompatibilities with |
2077 | the previous public versions of Lua, | 2077 | the previous public versions of Lua, |
@@ -2082,7 +2082,7 @@ Here is a list of all these differences. | |||
2082 | \begin{itemize} | 2082 | \begin{itemize} |
2083 | \item | 2083 | \item |
2084 | Functions \verb'date' and \verb'time' (from \verb'iolib') | 2084 | Functions \verb'date' and \verb'time' (from \verb'iolib') |
2085 | have been superseded by the new version of function \verb'date'. | 2085 | have been superseded by the new, more powerful version of function \verb'date'. |
2086 | \item | 2086 | \item |
2087 | Function \verb'append' (from \verb'iolib') now returns 1 whenever it succeeds, | 2087 | Function \verb'append' (from \verb'iolib') now returns 1 whenever it succeeds, |
2088 | whether the file is new or not. | 2088 | whether the file is new or not. |
@@ -2094,7 +2094,7 @@ The API lock mechanism has been superseded by the reference mechanism. | |||
2094 | However, \verb-lua.h- provides compatibility macros, | 2094 | However, \verb-lua.h- provides compatibility macros, |
2095 | so there is no need to change programs. | 2095 | so there is no need to change programs. |
2096 | \item | 2096 | \item |
2097 | API function \verb'lua_pushliteral' now is just a macro to | 2097 | The API function \verb'lua_pushliteral' now is just a macro to |
2098 | \verb'lua_pushstring'. | 2098 | \verb'lua_pushstring'. |
2099 | \end{itemize} | 2099 | \end{itemize} |
2100 | 2100 | ||
@@ -2145,11 +2145,11 @@ int lua_storesubscript (void); | |||
2145 | with the parameters explicitly pushed on the stack. | 2145 | with the parameters explicitly pushed on the stack. |
2146 | \item | 2146 | \item |
2147 | The functionality of the function \verb'lua_errorfunction' has been | 2147 | The functionality of the function \verb'lua_errorfunction' has been |
2148 | replaced by the {\em fallback} mechanism; \see{error}. | 2148 | replaced by the {\em fallback} mechanism (\see{error}). |
2149 | \item | 2149 | \item |
2150 | When calling a function from the Lua library, | 2150 | When calling a function from the Lua library, |
2151 | parameters passed through the stack | 2151 | parameters passed through the stack |
2152 | must be pushed just before the correspondent call, | 2152 | must be pushed just before the corresponding call, |
2153 | with no intermediate calls to Lua. | 2153 | with no intermediate calls to Lua. |
2154 | Special care should be taken with macros like | 2154 | Special care should be taken with macros like |
2155 | \verb'lua_getindexed' and \verb'lua_getfield'. | 2155 | \verb'lua_getindexed' and \verb'lua_getfield'. |