| @@ -2,16 +2,14 @@ · 1 unmodified line |
| 2 | <html> | 2 | <html> |
| 3 | | 3 | |
| 4 | <head> | 4 | <head> |
| 5 | <title>Lua 5.0 Reference Manual</title> | 5 | <TITLE>Lua: 5.0 reference manual</TITLE> |
| 6 | </head> | 6 | </head> |
| 7 | | 7 | |
| 8 | <body BGCOLOR="#FFFFFF"> | 8 | <body BGCOLOR="#FFFFFF"> |
| 9 | | 9 | |
| 10 | <hr> | 10 | <hr> |
| 11 | <h1> | 11 | <h1> |
| 12 | <a HREF="http://www.lua.org/home.html"> | 12 | <A HREF="http://www.lua.org/home.html"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A> |
| 13 | <img SRC="logo.gif" ALT="[Lua logo]" BORDER=0> | | |
| 14 | </a> | | |
| 15 | Lua 5.0 Reference Manual | 13 | Lua 5.0 Reference Manual |
| 16 | </h1> | 14 | </h1> |
| 17 | | 15 | |
| @@ -19,7 +17,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes · 1 unmodified line |
| 19 | <p> | 17 | <p> |
| 20 | <small> | 18 | <small> |
| 21 | <a HREF="http://www.lua.org/copyright.html">Copyright</a> | 19 | <a HREF="http://www.lua.org/copyright.html">Copyright</a> |
| 22 | © 2003 TeCGraf, PUC-Rio. All rights reserved. | 20 | © 2003 Tecgraf, PUC-Rio. All rights reserved. |
| 23 | </small> | 21 | </small> |
| 24 | <hr> | 22 | <hr> |
| 25 | | 23 | |
| @@ -29,12 +27,12 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes · 3 unmodified lines |
| 29 | | 27 | |
| 30 | | 28 | |
| 31 | | 29 | |
| 32 | <h1>1 - Introduction</h1> | 30 | <a name="1"><h1>1 - Introduction</h1></a> |
| 33 | | 31 | |
| 34 | <p>Lua is an extension programming language designed to support | 32 | <p>Lua is an extension programming language designed to support |
| 35 | general procedural programming with data description | 33 | general procedural programming with data description |
| 36 | facilities. | 34 | facilities. |
| 37 | It also offers good suport for object-oriented programming, | 35 | It also offers good support for object-oriented programming, |
| 38 | functional programming, and data-driven programming. | 36 | functional programming, and data-driven programming. |
| 39 | Lua is intended to be used as a powerful, light-weight | 37 | Lua is intended to be used as a powerful, light-weight |
| 40 | configuration language for any program that needs one. | 38 | configuration language for any program that needs one. |
| @@ -51,7 +49,7 @@ Through the use of C functions, Lua can be augmented to cope with · 10 unmodified lines |
| 51 | a wide range of different domains, | 49 | a wide range of different domains, |
| 52 | thus creating customized programming languages sharing a syntactical framework. | 50 | thus creating customized programming languages sharing a syntactical framework. |
| 53 | | 51 | |
| 54 | <p>The Lua distribuition includes a stand-alone embedding program, | 52 | <p>The Lua distribution includes a stand-alone embedding program, |
| 55 | <code>lua</code>, that uses the Lua library to offer a complete Lua interpreter. | 53 | <code>lua</code>, that uses the Lua library to offer a complete Lua interpreter. |
| 56 | | 54 | |
| 57 | <p>Lua is free software, | 55 | <p>Lua is free software, |
| @@ -87,7 +85,7 @@ The evolution of an extension language: a history of Lua, · 29 unmodified lines |
| 87 | <p>Lua means "moon" in Portuguese and is pronounced LOO-ah. | 85 | <p>Lua means "moon" in Portuguese and is pronounced LOO-ah. |
| 88 | | 86 | |
| 89 | <p> | 87 | <p> |
| 90 | <a name="language"><h1>2 - The Language</h1></a> | 88 | <a name="language"><a name="2"><h1>2 - The Language</h1></a></a> |
| 91 | | 89 | |
| 92 | <p>This section describes the lexis, the syntax, and the semantics of Lua. | 90 | <p>This section describes the lexis, the syntax, and the semantics of Lua. |
| 93 | In other words, | 91 | In other words, |
| @@ -105,7 +103,7 @@ keywords are shown in <b>bold</b>, · 11 unmodified lines |
| 105 | and other terminal symbols are shown in <code>typewriter</code> font, | 103 | and other terminal symbols are shown in <code>typewriter</code> font, |
| 106 | enclosed in single quotes. | 104 | enclosed in single quotes. |
| 107 | | 105 | |
| 108 | <p><a name="lexical"><h2>2.1 - Lexical Conventions</h2></a> | 106 | <p><a name="lexical"><a name="2.1"><h2>2.1 - Lexical Conventions</h2></a></a> |
| 109 | | 107 | |
| 110 | <p><em>Identifiers</em> in Lua can be any string of letters, | 108 | <p><em>Identifiers</em> in Lua can be any string of letters, |
| 111 | digits, and underscores, | 109 | digits, and underscores, |
| @@ -122,8 +120,7 @@ and cannot be used as identifiers: · 10 unmodified lines |
| 122 | and break do else elseif | 120 | and break do else elseif |
| 123 | end false for function if | 121 | end false for function if |
| 124 | in local nil not or | 122 | in local nil not or |
| 125 | repeat return then true until | 123 | repeat return then true until while |
| 126 | while | | |
| 127 | </PRE> | 124 | </PRE> |
| 128 | | 125 | |
| 129 | <p>Lua is a case-sensitive language: | 126 | <p>Lua is a case-sensitive language: |
| @@ -211,7 +208,7 @@ the first line of a chunk is skipped if it starts with <code>#</code>. · 81 unmodified lines |
| 211 | This facility allows the use of Lua as a script interpreter | 208 | This facility allows the use of Lua as a script interpreter |
| 212 | in Unix systems (see <a href="#lua-sa">6</a>). | 209 | in Unix systems (see <a href="#lua-sa">6</a>). |
| 213 | | 210 | |
| 214 | <p><a name="TypesSec"><h2>2.2 - Values and Types</h2></a> | 211 | <p><a name="TypesSec"><a name="2.2"><h2>2.2 - Values and Types</h2></a></a> |
| 215 | | 212 | |
| 216 | <p>Lua is a <em>dynamically typed language</em>. | 213 | <p>Lua is a <em>dynamically typed language</em>. |
| 217 | That means that | 214 | That means that |
| @@ -292,7 +289,7 @@ these operations do not imply any kind of copy. · 74 unmodified lines |
| 292 | <p>The library function <code>type</code> returns a string describing the type | 289 | <p>The library function <code>type</code> returns a string describing the type |
| 293 | of a given value (see <a href="#pdf-type">5.1</a>). | 290 | of a given value (see <a href="#pdf-type">5.1</a>). |
| 294 | | 291 | |
| 295 | <p><a name="coercion"><h3>2.2.1 - Coercion</h3></a> | 292 | <p><a name="coercion"><a name="2.2.1"><h3>2.2.1 - Coercion</h3></a></a> |
| 296 | | 293 | |
| 297 | <p>Lua provides automatic conversion between | 294 | <p>Lua provides automatic conversion between |
| 298 | string and number values at run time. | 295 | string and number values at run time. |
| @@ -303,7 +300,7 @@ the number is converted to a string, in a reasonable format. · 4 unmodified lines |
| 303 | For complete control of how numbers are converted to strings, | 300 | For complete control of how numbers are converted to strings, |
| 304 | use the <code>format</code> function from the string library (see <a href="#format">5.3</a>). | 301 | use the <code>format</code> function from the string library (see <a href="#format">5.3</a>). |
| 305 | | 302 | |
| 306 | <p><a name="variables"><h2>2.3 - Variables</h2></a> | 303 | <p><a name="variables"><a name="2.3"><h2>2.3 - Variables</h2></a></a> |
| 307 | | 304 | |
| 308 | <p>Variables are places that store values. | 305 | <p>Variables are places that store values. |
| 309 | | 306 | |
| @@ -372,7 +369,7 @@ where <code>_env</code> is the environment of the running function. · 62 unmodified lines |
| 372 | (The <code>_env</code> variable is not defined in Lua. | 369 | (The <code>_env</code> variable is not defined in Lua. |
| 373 | We use it here only for explanatory purposes.) | 370 | We use it here only for explanatory purposes.) |
| 374 | | 371 | |
| 375 | <p><a name="stats"><h2>2.4 - Statements</h2></a> | 372 | <p><a name="stats"><a name="2.4"><h2>2.4 - Statements</h2></a></a> |
| 376 | | 373 | |
| 377 | <p>Lua supports an almost conventional set of statements, | 374 | <p>Lua supports an almost conventional set of statements, |
| 378 | similar to those in Pascal or C. | 375 | similar to those in Pascal or C. |
| @@ -380,7 +377,7 @@ This set includes · 1 unmodified line |
| 380 | assignment, control structures, procedure calls, | 377 | assignment, control structures, procedure calls, |
| 381 | table constructors, and variable declarations. | 378 | table constructors, and variable declarations. |
| 382 | | 379 | |
| 383 | <p><a name="chunks"><h3>2.4.1 - Chunks</h3></a> | 380 | <p><a name="chunks"><a name="2.4.1"><h3>2.4.1 - Chunks</h3></a></a> |
| 384 | | 381 | |
| 385 | <p>The unit of execution of Lua is called a <em>chunk</em>. | 382 | <p>The unit of execution of Lua is called a <em>chunk</em>. |
| 386 | A chunk is simply a sequence of statements, | 383 | A chunk is simply a sequence of statements, |
| @@ -405,7 +402,7 @@ Programs in source and compiled forms are interchangeable; · 18 unmodified lines |
| 405 | Lua automatically detects the file type and acts accordingly. | 402 | Lua automatically detects the file type and acts accordingly. |
| 406 | | 403 | |
| 407 | | 404 | |
| 408 | <p><h3>2.4.2 - Blocks</h3> | 405 | <p><a name="2.4.2"><h3>2.4.2 - Blocks</h3></a> |
| 409 | A block is a list of statements; | 406 | A block is a list of statements; |
| 410 | syntactically, a block is equal to a chunk: | 407 | syntactically, a block is equal to a chunk: |
| 411 | <pre> | 408 | <pre> |
| @@ -423,7 +420,7 @@ add a <b>return</b> or <b>break</b> statement in the middle · 11 unmodified lines |
| 423 | of another block (see <a href="#control">2.4.4</a>). | 420 | of another block (see <a href="#control">2.4.4</a>). |
| 424 | | 421 | |
| 425 | | 422 | |
| 426 | <p><a name="assignment"><h3>2.4.3 - Assignment</h3></a> | 423 | <p><a name="assignment"><a name="2.4.3"><h3>2.4.3 - Assignment</h3></a></a> |
| 427 | | 424 | |
| 428 | <p>Lua allows multiple assignment. | 425 | <p>Lua allows multiple assignment. |
| 429 | Therefore, the syntax for assignment | 426 | Therefore, the syntax for assignment |
| @@ -458,7 +455,7 @@ Thus the code · 28 unmodified lines |
| 458 | </PRE> | 455 | </PRE> |
| 459 | sets <code>a[3]</code> to 20, without affecting <code>a[4]</code> | 456 | sets <code>a[3]</code> to 20, without affecting <code>a[4]</code> |
| 460 | because the <code>i</code> in <code>a[i]</code> is evaluated (to 3) | 457 | because the <code>i</code> in <code>a[i]</code> is evaluated (to 3) |
| 461 | before it is assigned 4. | 458 | before it is assigned 4. |
| 462 | Similarly, the line | 459 | Similarly, the line |
| 463 | <PRE> | 460 | <PRE> |
| 464 | x, y = y, x | 461 | x, y = y, x |
| @@ -485,7 +482,7 @@ where <code>_env</code> is the environment of the running function. · 20 unmodified lines |
| 485 | (The <code>_env</code> variable is not defined in Lua. | 482 | (The <code>_env</code> variable is not defined in Lua. |
| 486 | We use it here only for explanatory purposes.) | 483 | We use it here only for explanatory purposes.) |
| 487 | | 484 | |
| 488 | <p><a name="control"><h3>2.4.4 - Control Structures</h3></a> | 485 | <p><a name="control"><a name="2.4.4"><h3>2.4.4 - Control Structures</h3></a></a> |
| 489 | The control structures | 486 | The control structures |
| 490 | <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and | 487 | <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and |
| 491 | familiar syntax: | 488 | familiar syntax: |
| @@ -516,7 +513,7 @@ so the syntax for the <b>return</b> statement is · 24 unmodified lines |
| 516 | | 513 | |
| 517 | <p>The <b>break</b> statement can be used to terminate the execution of a | 514 | <p>The <b>break</b> statement can be used to terminate the execution of a |
| 518 | <b>while</b>, <b>repeat</b>, or <b>for</b> loop, | 515 | <b>while</b>, <b>repeat</b>, or <b>for</b> loop, |
| 519 | skiping to the next statement after the loop: | 516 | skipping to the next statement after the loop: |
| 520 | | 517 | |
| 521 | <pre> | 518 | <pre> |
| 522 | stat ::= <b>break</b> | 519 | stat ::= <b>break</b> |
| @@ -536,7 +533,7 @@ their (inner) blocks. · 13 unmodified lines |
| 536 | In practice, | 533 | In practice, |
| 537 | those idioms are only used during debugging. | 534 | those idioms are only used during debugging. |
| 538 | | 535 | |
| 539 | <p><a name="for"><h3>2.4.5 - For Statement</h3></a> | 536 | <p><a name="for"><a name="2.4.5"><h3>2.4.5 - For Statement</h3></a></a> |
| 540 | | 537 | |
| 541 | <p>The <b>for</b> statement has two forms: | 538 | <p>The <b>for</b> statement has two forms: |
| 542 | one numeric and one generic. | 539 | one numeric and one generic. |
| @@ -623,7 +620,7 @@ If you need these values, · 80 unmodified lines |
| 623 | then assign them to other variables before breaking or exiting the loop. | 620 | then assign them to other variables before breaking or exiting the loop. |
| 624 | </ul> | 621 | </ul> |
| 625 | | 622 | |
| 626 | <p><a name="funcstat"><h3>2.4.6 - Function Calls as Statements</h3></a> | 623 | <p><a name="funcstat"><a name="2.4.6"><h3>2.4.6 - Function Calls as Statements</h3></a></a> |
| 627 | To allow possible side-effects, | 624 | To allow possible side-effects, |
| 628 | function calls can be executed as statements: | 625 | function calls can be executed as statements: |
| 629 | <pre> | 626 | <pre> |
| @@ -632,7 +629,7 @@ function calls can be executed as statements: · 2 unmodified lines |
| 632 | In this case, all returned values are thrown away. | 629 | In this case, all returned values are thrown away. |
| 633 | Function calls are explained in <a href="#functioncall">2.5.7</a>. | 630 | Function calls are explained in <a href="#functioncall">2.5.7</a>. |
| 634 | | 631 | |
| 635 | <p><a name="localvar"><h3>2.4.7 - Local Declarations</h3></a> | 632 | <p><a name="localvar"><a name="2.4.7"><h3>2.4.7 - Local Declarations</h3></a></a> |
| 636 | Local variables may be declared anywhere inside a block. | 633 | Local variables may be declared anywhere inside a block. |
| 637 | The declaration may include an initial assignment: | 634 | The declaration may include an initial assignment: |
| 638 | <pre> | 635 | <pre> |
| @@ -649,7 +646,7 @@ Such local variables die when the chunk ends. · 10 unmodified lines |
| 649 | | 646 | |
| 650 | <p>The visibility rules for local variables are explained in <a href="#visibility">2.6</a>. | 647 | <p>The visibility rules for local variables are explained in <a href="#visibility">2.6</a>. |
| 651 | | 648 | |
| 652 | <p><a name="expressions"><h2>2.5 - Expressions</h2></a> | 649 | <p><a name="expressions"><a name="2.5"><h2>2.5 - Expressions</h2></a></a> |
| 653 | | 650 | |
| 654 | <p> | 651 | <p> |
| 655 | The basic expressions in Lua are the following: | 652 | The basic expressions in Lua are the following: |
| @@ -680,7 +677,7 @@ or <B>nil</B> if <code>f</code> does not return any values.) · 24 unmodified lines |
| 680 | <p>Expressions can also be built with arithmetic operators, relational operators, | 677 | <p>Expressions can also be built with arithmetic operators, relational operators, |
| 681 | and logical operators, all of which are explained below. | 678 | and logical operators, all of which are explained below. |
| 682 | | 679 | |
| 683 | <p><h3>2.5.1 - Arithmetic Operators</h3> | 680 | <p><a name="2.5.1"><h3>2.5.1 - Arithmetic Operators</h3></a> |
| 684 | Lua supports the usual arithmetic operators: | 681 | Lua supports the usual arithmetic operators: |
| 685 | the binary <code>+</code> (addition), | 682 | the binary <code>+</code> (addition), |
| 686 | <code>-</code> (subtraction), <code>*</code> (multiplication), | 683 | <code>-</code> (subtraction), <code>*</code> (multiplication), |
| @@ -695,7 +692,7 @@ The standard mathematical library defines function <code>__pow</code>, · 8 unmodified lines |
| 695 | giving the expected meaning to exponentiation | 692 | giving the expected meaning to exponentiation |
| 696 | (see <a href="#mathlib">5.5</a>). | 693 | (see <a href="#mathlib">5.5</a>). |
| 697 | | 694 | |
| 698 | <p><a name="rel-ops"><h3>2.5.2 - Relational Operators</h3></a> | 695 | <p><a name="rel-ops"><a name="2.5.2"><h3>2.5.2 - Relational Operators</h3></a></a> |
| 699 | The relational operators in Lua are | 696 | The relational operators in Lua are |
| 700 | <PRE> | 697 | <PRE> |
| 701 | == ~= < > <= >= | 698 | == ~= < > <= >= |
| @@ -731,7 +728,7 @@ then their values are compared according to the current locale. · 29 unmodified lines |
| 731 | Otherwise, Lua tries to call the "lt" or the "le" | 728 | Otherwise, Lua tries to call the "lt" or the "le" |
| 732 | metamethod (see <a href="#metatable">2.8</a>). | 729 | metamethod (see <a href="#metatable">2.8</a>). |
| 733 | | 730 | |
| 734 | <p><h3>2.5.3 - Logical Operators</h3> | 731 | <p><a name="2.5.3"><h3>2.5.3 - Logical Operators</h3></a> |
| 735 | The logical operators in Lua are | 732 | The logical operators in Lua are |
| 736 | | 733 | |
| 737 | <PRE> | 734 | <PRE> |
| @@ -764,14 +761,14 @@ For example, · 26 unmodified lines |
| 764 | 10 and 20 -> 20 | 761 | 10 and 20 -> 20 |
| 765 | </PRE> | 762 | </PRE> |
| 766 | | 763 | |
| 767 | <p><a name="concat"><h3>2.5.4 - Concatenation</h3></a> | 764 | <p><a name="concat"><a name="2.5.4"><h3>2.5.4 - Concatenation</h3></a></a> |
| 768 | The string concatenation operator in Lua is | 765 | The string concatenation operator in Lua is |
| 769 | denoted by two dots (`<code>..</code>´). | 766 | denoted by two dots (`<code>..</code>´). |
| 770 | If both operands are strings or numbers, then they are converted to | 767 | If both operands are strings or numbers, then they are converted to |
| 771 | strings according to the rules mentioned in <a href="#coercion">2.2.1</a>. | 768 | strings according to the rules mentioned in <a href="#coercion">2.2.1</a>. |
| 772 | Otherwise, the "concat" metamethod is called (see <a href="#metatable">2.8</a>). | 769 | Otherwise, the "concat" metamethod is called (see <a href="#metatable">2.8</a>). |
| 773 | | 770 | |
| 774 | <p><h3>2.5.5 - Precedence</h3> | 771 | <p><a name="2.5.5"><h3>2.5.5 - Precedence</h3></a> |
| 775 | Operator precedence in Lua follows the table below, | 772 | Operator precedence in Lua follows the table below, |
| 776 | from lower to higher priority: | 773 | from lower to higher priority: |
| 777 | <PRE> | 774 | <PRE> |
| @@ -784,12 +781,12 @@ from lower to higher priority: · 6 unmodified lines |
| 784 | not - (unary) | 781 | not - (unary) |
| 785 | ^ | 782 | ^ |
| 786 | </PRE> | 783 | </PRE> |
| 787 | As usual, you can use parentheses to change the precedences of an expression. | 784 | You can use parentheses to change the precedences in an expression. |
| 788 | The concatenation (`<code>..</code>´) and exponentiation (`<code>^</code>´) | 785 | The concatenation (`<code>..</code>´) and exponentiation (`<code>^</code>´) |
| 789 | operators are right associative. | 786 | operators are right associative. |
| 790 | All other binary operators are left associative. | 787 | All other binary operators are left associative. |
| 791 | | 788 | |
| 792 | <p><a name="tableconstructor"><h3>2.5.6 - Table Constructors</h3></a> | 789 | <p><a name="tableconstructor"><a name="2.5.6"><h3>2.5.6 - Table Constructors</h3></a></a> |
| 793 | Table constructors are expressions that create tables. | 790 | Table constructors are expressions that create tables. |
| 794 | Every time a constructor is evaluated, a new table is created. | 791 | Every time a constructor is evaluated, a new table is created. |
| 795 | Constructors can be used to create empty tables, | 792 | Constructors can be used to create empty tables, |
| @@ -839,7 +836,7 @@ enclose the function call in parentheses (see <a href="#expressions">2.5</a>). · 43 unmodified lines |
| 839 | <p>The field list may have an optional trailing separator, | 836 | <p>The field list may have an optional trailing separator, |
| 840 | as a convenience for machine-generated code. | 837 | as a convenience for machine-generated code. |
| 841 | | 838 | |
| 842 | <p><a name="functioncall"><h3>2.5.7 - Function Calls</h3></a> | 839 | <p><a name="functioncall"><a name="2.5.7"><h3>2.5.7 - Function Calls</h3></a></a> |
| 843 | A function call in Lua has the following syntax: | 840 | A function call in Lua has the following syntax: |
| 844 | <pre> | 841 | <pre> |
| 845 | functioncall ::= prefixexp args | 842 | functioncall ::= prefixexp args |
| @@ -944,12 +941,12 @@ So, all the following examples are not tails calls: · 98 unmodified lines |
| 944 | <PRE> | 941 | <PRE> |
| 945 | return (f(x)) -- results adjusted to 1 | 942 | return (f(x)) -- results adjusted to 1 |
| 946 | return 2 * f(x) | 943 | return 2 * f(x) |
| 947 | return x, f(x) -- adicional results | 944 | return x, f(x) -- additional results |
| 948 | f(x); return -- results discarded | 945 | f(x); return -- results discarded |
| 949 | return x or f(x) -- results adjusted to 1 | 946 | return x or f(x) -- results adjusted to 1 |
| 950 | </PRE> | 947 | </PRE> |
| 951 | | 948 | |
| 952 | <p><a name="func-def"><h3>2.5.8 - Function Definitions</h3></a> | 949 | <p><a name="func-def"><a name="2.5.8"><h3>2.5.8 - Function Definitions</h3></a></a> |
| 953 | | 950 | |
| 954 | <p>The syntax for function definition is | 951 | <p>The syntax for function definition is |
| 955 | <pre> | 952 | <pre> |
| @@ -1058,7 +1055,7 @@ is syntactic sugar for · 102 unmodified lines |
| 1058 | t.a.b.c.f = function (self, ...) ... end | 1055 | t.a.b.c.f = function (self, ...) ... end |
| 1059 | </PRE> | 1056 | </PRE> |
| 1060 | | 1057 | |
| 1061 | <p><a name="visibility"><h2>2.6 - Visibility Rules</h2></a> | 1058 | <p><a name="visibility"><a name="2.6"><h2>2.6 - Visibility Rules</h2></a></a> |
| 1062 | | 1059 | |
| 1063 | | 1060 | |
| 1064 | <p>Lua is a lexically scoped language. | 1061 | <p>Lua is a lexically scoped language. |
| @@ -1115,7 +1112,7 @@ The loop creates ten closures · 50 unmodified lines |
| 1115 | Each of these closures uses a different <code>y</code> variable, | 1112 | Each of these closures uses a different <code>y</code> variable, |
| 1116 | while all of them share the same <code>x</code>. | 1113 | while all of them share the same <code>x</code>. |
| 1117 | | 1114 | |
| 1118 | <p><a name="error"><h2>2.7 - Error Handling</h2></a> | 1115 | <p><a name="error"><a name="2.7"><h2>2.7 - Error Handling</h2></a></a> |
| 1119 | | 1116 | |
| 1120 | <p>Because Lua is an extension language, | 1117 | <p>Because Lua is an extension language, |
| 1121 | all Lua actions start from C code in the host program | 1118 | all Lua actions start from C code in the host program |
| @@ -1130,7 +1127,7 @@ which can take appropriate measures · 8 unmodified lines |
| 1130 | If you need to catch errors in Lua, | 1127 | If you need to catch errors in Lua, |
| 1131 | you can use the <code>pcall</code> function (see <a href="#pdf-pcall">5.1</a>). | 1128 | you can use the <code>pcall</code> function (see <a href="#pdf-pcall">5.1</a>). |
| 1132 | | 1129 | |
| 1133 | <p><a name="metatable"><h2>2.8 - Metatables</h2></a> | 1130 | <p><a name="metatable"><a name="2.8"><h2>2.8 - Metatables</h2></a></a> |
| 1134 | | 1131 | |
| 1135 | <p>Every table and userdata object in Lua may have a <em>metatable</em>. | 1132 | <p>Every table and userdata object in Lua may have a <em>metatable</em>. |
| 1136 | This <em>metatable</em> is an ordinary Lua table | 1133 | This <em>metatable</em> is an ordinary Lua table |
| @@ -1312,7 +1309,7 @@ and the same metamethod for the selected operation. · 175 unmodified lines |
| 1312 | The "eq" event is defined as follows: | 1309 | The "eq" event is defined as follows: |
| 1313 | <PRE> | 1310 | <PRE> |
| 1314 | function eq_event (op1, op2) | 1311 | function eq_event (op1, op2) |
| 1315 | if type(op1) ~= type(op2) then -- diferent types? | 1312 | if type(op1) ~= type(op2) then -- different types? |
| 1316 | return false -- different objects | 1313 | return false -- different objects |
| 1317 | end | 1314 | end |
| 1318 | if op1 == op2 then -- primitive equal? | 1315 | if op1 == op2 then -- primitive equal? |
| @@ -1440,7 +1437,7 @@ called when Lua calls a value. · 121 unmodified lines |
| 1440 | | 1437 | |
| 1441 | <p></ul> | 1438 | <p></ul> |
| 1442 | | 1439 | |
| 1443 | <p><a name="GC"><h2>2.9 - Garbage Collection</h2></a> | 1440 | <p><a name="GC"><a name="2.9"><h2>2.9 - Garbage Collection</h2></a></a> |
| 1444 | | 1441 | |
| 1445 | <p>Lua does automatic memory management. | 1442 | <p>Lua does automatic memory management. |
| 1446 | That means that | 1443 | That means that |
| @@ -1471,7 +1468,7 @@ Using Lua code you have a more limited control over garbage-collection cycles, · 24 unmodified lines |
| 1471 | through the <code>gcinfo</code> and <code>collectgarbage</code> functions | 1468 | through the <code>gcinfo</code> and <code>collectgarbage</code> functions |
| 1472 | (see <a href="#predefined">5.1</a>). | 1469 | (see <a href="#predefined">5.1</a>). |
| 1473 | | 1470 | |
| 1474 | <p><h3>2.9.1 - Garbage-Collection Metamethods</h3> | 1471 | <p><a name="2.9.1"><h3>2.9.1 - Garbage-Collection Metamethods</h3></a> |
| 1475 | | 1472 | |
| 1476 | <p>Using the C API, | 1473 | <p>Using the C API, |
| 1477 | you can set garbage-collector metamethods for userdata (see <a href="#metatable">2.8</a>). | 1474 | you can set garbage-collector metamethods for userdata (see <a href="#metatable">2.8</a>). |
| @@ -1503,7 +1500,7 @@ among those collected in that cycle. · 25 unmodified lines |
| 1503 | That is, the first finalizer to be called is the one associated | 1500 | That is, the first finalizer to be called is the one associated |
| 1504 | with the userdata created last in the program. | 1501 | with the userdata created last in the program. |
| 1505 | | 1502 | |
| 1506 | <p><a name="weak-table"><h3>2.9.2 - Weak Tables</h3></a> | 1503 | <p><a name="weak-table"><a name="2.9.2"><h3>2.9.2 - Weak Tables</h3></a></a> |
| 1507 | | 1504 | |
| 1508 | <p>A <em>weak table</em> is a table whose elements are | 1505 | <p>A <em>weak table</em> is a table whose elements are |
| 1509 | <em>weak references</em>. | 1506 | <em>weak references</em>. |
| @@ -1521,7 +1518,7 @@ In any case, if either the key or the value is collected, · 11 unmodified lines |
| 1521 | the whole pair is removed from the table. | 1518 | the whole pair is removed from the table. |
| 1522 | The weakness of a table is controlled by the value of the | 1519 | The weakness of a table is controlled by the value of the |
| 1523 | <code>__mode</code> field of its metatable. | 1520 | <code>__mode</code> field of its metatable. |
| 1524 | If the <code>__mode</code> field is a string containing the character `<code>k</code>´, | 1521 | If the <code>__mode</code> field is a string containing the character `<code>k</code>´, |
| 1525 | the keys in the table are weak. | 1522 | the keys in the table are weak. |
| 1526 | If <code>__mode</code> contains `<code>v</code>´, | 1523 | If <code>__mode</code> contains `<code>v</code>´, |
| 1527 | the values in the table are weak. | 1524 | the values in the table are weak. |
| @@ -1531,7 +1528,7 @@ you should not change the value of its field <code>__mode</code>. · 3 unmodified lines |
| 1531 | Otherwise, the weak behavior of the tables controlled by this | 1528 | Otherwise, the weak behavior of the tables controlled by this |
| 1532 | metatable is undefined. | 1529 | metatable is undefined. |
| 1533 | | 1530 | |
| 1534 | <p><a name="coroutine"><h2>2.10 - Coroutines</h2></a> | 1531 | <p><a name="coroutine"><a name="2.10"><h2>2.10 - Coroutines</h2></a></a> |
| 1535 | | 1532 | |
| 1536 | <p>Lua supports coroutines, | 1533 | <p>Lua supports coroutines, |
| 1537 | also called <em>semi-coroutines</em> | 1534 | also called <em>semi-coroutines</em> |
| @@ -1549,7 +1546,7 @@ returns a handle to it (an object of type <em>thread</em>); · 11 unmodified lines |
| 1549 | it does not start the coroutine execution. | 1546 | it does not start the coroutine execution. |
| 1550 | | 1547 | |
| 1551 | <p>When you first call <code>coroutine.resume</code>, | 1548 | <p>When you first call <code>coroutine.resume</code>, |
| 1552 | passing as argument the thread returned by <code>coroutine.create</code>, | 1549 | passing as its first argument the thread returned by <code>coroutine.create</code>, |
| 1553 | the coroutine starts its execution, | 1550 | the coroutine starts its execution, |
| 1554 | at the first line of its main function. | 1551 | at the first line of its main function. |
| 1555 | Extra arguments passed to <code>coroutine.resume</code> are given as | 1552 | Extra arguments passed to <code>coroutine.resume</code> are given as |
| @@ -1630,7 +1627,7 @@ main false cannot resume dead coroutine · 74 unmodified lines |
| 1630 | </PRE> | 1627 | </PRE> |
| 1631 | | 1628 | |
| 1632 | <p> | 1629 | <p> |
| 1633 | <a name="API"><h1>3 - The Application Program Interface</h1></a> | 1630 | <a name="API"><a name="3"><h1>3 - The Application Program Interface</h1></a></a> |
| 1634 | | 1631 | |
| 1635 | | 1632 | |
| 1636 | <p>This section describes the C API for Lua, that is, | 1633 | <p>This section describes the C API for Lua, that is, |
| @@ -1645,7 +1642,7 @@ All such macros use each of its arguments exactly once · 8 unmodified lines |
| 1645 | (except for the first argument, which is always a Lua state), | 1642 | (except for the first argument, which is always a Lua state), |
| 1646 | and so do not generate hidden side-effects. | 1643 | and so do not generate hidden side-effects. |
| 1647 | | 1644 | |
| 1648 | <p><a name="mangstate"><h2>3.1 - States</h2></a> | 1645 | <p><a name="mangstate"><a name="3.1"><h2>3.1 - States</h2></a></a> |
| 1649 | | 1646 | |
| 1650 | <p>The Lua library is fully reentrant: | 1647 | <p>The Lua library is fully reentrant: |
| 1651 | it has no global variables. | 1648 | it has no global variables. |
| @@ -1681,7 +1678,7 @@ such as a daemon or a web server, · 29 unmodified lines |
| 1681 | might need to release states as soon as they are not needed, | 1678 | might need to release states as soon as they are not needed, |
| 1682 | to avoid growing too large. | 1679 | to avoid growing too large. |
| 1683 | | 1680 | |
| 1684 | <p><h2>3.2 - The Stack and Indices</h2> | 1681 | <p><a name="3.2"><h2>3.2 - The Stack and Indices</h2></a> |
| 1685 | | 1682 | |
| 1686 | <p>Lua uses a <em>virtual stack</em> to pass values to and from C. | 1683 | <p>Lua uses a <em>virtual stack</em> to pass values to and from C. |
| 1687 | Each element in this stack represents a Lua value | 1684 | Each element in this stack represents a Lua value |
| @@ -1691,7 +1688,7 @@ Each element in this stack represents a Lua value · 3 unmodified lines |
| 1691 | which is independent of previous stacks and of stacks of | 1688 | which is independent of previous stacks and of stacks of |
| 1692 | C functions that are still active. | 1689 | C functions that are still active. |
| 1693 | That stack initially contains any arguments to the C function, | 1690 | That stack initially contains any arguments to the C function, |
| 1694 | and it is where the C function pushes its results (see <a href="#LuacallC">3.16</a>) | 1691 | and it is where the C function pushes its results to be returned to the caller (see <a href="#LuacallC">3.16</a>) |
| 1695 | to be returned to the caller. | 1692 | to be returned to the caller. |
| 1696 | | 1693 | |
| 1697 | <p>For convenience, | 1694 | <p>For convenience, |
| @@ -1736,7 +1733,7 @@ if the stack is already larger than the new size, · 38 unmodified lines |
| 1736 | it is left unchanged. | 1733 | it is left unchanged. |
| 1737 | | 1734 | |
| 1738 | <p>Whenever Lua calls C, | 1735 | <p>Whenever Lua calls C, |
| 1739 | it ensures that at least <code>LUA_MINSTACK</code> positions are available. | 1736 | it ensures that at least <code>LUA_MINSTACK</code> stack positions are available. |
| 1740 | <code>LUA_MINSTACK</code> is defined in <code>lua.h</code> as 20, | 1737 | <code>LUA_MINSTACK</code> is defined in <code>lua.h</code> as 20, |
| 1741 | so that usually you do not have to worry about stack space | 1738 | so that usually you do not have to worry about stack space |
| 1742 | unless your code has loops pushing elements onto the stack. | 1739 | unless your code has loops pushing elements onto the stack. |
| @@ -1760,7 +1757,7 @@ but are not in the stack. · 17 unmodified lines |
| 1760 | Pseudo-indices are used to access the global environment, | 1757 | Pseudo-indices are used to access the global environment, |
| 1761 | the registry, and the upvalues of a C function (see <a href="#c-closure">3.17</a>). | 1758 | the registry, and the upvalues of a C function (see <a href="#c-closure">3.17</a>). |
| 1762 | | 1759 | |
| 1763 | <p><h2>3.3 - Stack Manipulation</h2> | 1760 | <p><a name="3.3"><h2>3.3 - Stack Manipulation</h2></a> |
| 1764 | The API offers the following functions for basic stack manipulation: | 1761 | The API offers the following functions for basic stack manipulation: |
| 1765 | <PRE> | 1762 | <PRE> |
| 1766 | void lua_settop (lua_State *L, int index); | 1763 | void lua_settop (lua_State *L, int index); |
| @@ -1813,7 +1810,7 @@ then · 46 unmodified lines |
| 1813 | lua_settop(L, 6) --> 30 40 nil nil nil nil* | 1810 | lua_settop(L, 6) --> 30 40 nil nil nil nil* |
| 1814 | </PRE> | 1811 | </PRE> |
| 1815 | | 1812 | |
| 1816 | <p><h2>3.4 - Querying the Stack</h2> | 1813 | <p><a name="3.4"><h2>3.4 - Querying the Stack</h2></a> |
| 1817 | | 1814 | |
| 1818 | <p>To check the type of a stack element, | 1815 | <p>To check the type of a stack element, |
| 1819 | the following functions are available: | 1816 | the following functions are available: |
| @@ -1887,7 +1884,7 @@ are equivalent to their counterparts in Lua (see <a href="#rel-ops">2.5.2</a>). · 67 unmodified lines |
| 1887 | without metamethods. | 1884 | without metamethods. |
| 1888 | These functions return 0 (false) if any of the indices are non-valid. | 1885 | These functions return 0 (false) if any of the indices are non-valid. |
| 1889 | | 1886 | |
| 1890 | <p><a name="lua-to"><h2>3.5 - Getting Values from the Stack</h2></a> | 1887 | <p><a name="lua-to"><a name="3.5"><h2>3.5 - Getting Values from the Stack</h2></a></a> |
| 1891 | | 1888 | |
| 1892 | <p>To translate a value in the stack to a specific C type, | 1889 | <p>To translate a value in the stack to a specific C type, |
| 1893 | you can use the following conversion functions: | 1890 | you can use the following conversion functions: |
| @@ -1966,7 +1963,7 @@ Typically this function is used for debug information. · 72 unmodified lines |
| 1966 | | 1963 | |
| 1967 | <p><code>lua_touserdata</code> is explained in <a href="#userdata">3.8</a>. | 1964 | <p><code>lua_touserdata</code> is explained in <a href="#userdata">3.8</a>. |
| 1968 | | 1965 | |
| 1969 | <p><a name="pushing"><h2>3.6 - Pushing Values onto the Stack</h2></a> | 1966 | <p><a name="pushing"><a name="3.6"><h2>3.6 - Pushing Values onto the Stack</h2></a></a> |
| 1970 | | 1967 | |
| 1971 | <p>The API has the following functions to | 1968 | <p>The API has the following functions to |
| 1972 | push C values onto the stack: | 1969 | push C values onto the stack: |
| @@ -1996,8 +1993,7 @@ which accepts an explicit size. · 23 unmodified lines |
| 1996 | <p>You can also push "formatted" strings: | 1993 | <p>You can also push "formatted" strings: |
| 1997 | <PRE> | 1994 | <PRE> |
| 1998 | const char *lua_pushfstring (lua_State *L, const char *fmt, ...); | 1995 | const char *lua_pushfstring (lua_State *L, const char *fmt, ...); |
| 1999 | const char *lua_pushvfstring (lua_State *L, const char *fmt, | 1996 | const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp); |
| 2000 | va_list argp); | | |
| 2001 | </PRE> | 1997 | </PRE> |
| 2002 | | 1998 | |
| 2003 | These functions push onto the stack a formatted string | 1999 | These functions push onto the stack a formatted string |
| @@ -2025,13 +2021,13 @@ The conversion specifiers can be simply · 21 unmodified lines |
| 2025 | | 2021 | |
| 2026 | concatenates the <code>n</code> values at the top of the stack, | 2022 | concatenates the <code>n</code> values at the top of the stack, |
| 2027 | pops them, and leaves the result at the top. | 2023 | pops them, and leaves the result at the top. |
| 2028 | If <code>n</code> is 1, the result is that single string | 2024 | If <code>n</code> is 1, the result is that single string |
| 2029 | (that is, the function does nothing); | 2025 | (that is, the function does nothing); |
| 2030 | if <code>n</code> is 0, the result is the empty string. | 2026 | if <code>n</code> is 0, the result is the empty string. |
| 2031 | Concatenation is done following the usual semantics of Lua | 2027 | Concatenation is done following the usual semantics of Lua |
| 2032 | (see <a href="#concat">2.5.4</a>). | 2028 | (see <a href="#concat">2.5.4</a>). |
| 2033 | | 2029 | |
| 2034 | <p><a name="GC-API"><h2>3.7 - Controlling Garbage Collection</h2></a> | 2030 | <p><a name="GC-API"><a name="3.7"><h2>3.7 - Controlling Garbage Collection</h2></a></a> |
| 2035 | | 2031 | |
| 2036 | <p>Lua uses two numbers to control its garbage collection: | 2032 | <p>Lua uses two numbers to control its garbage collection: |
| 2037 | the <em>count</em> and the <em>threshold</em> (see <a href="#GC">2.9</a>). | 2033 | the <em>count</em> and the <em>threshold</em> (see <a href="#GC">2.9</a>). |
| @@ -2044,7 +2040,7 @@ and the threshold is set to twice the count value. · 6 unmodified lines |
| 2044 | <p>You can access the current values of these two numbers through the | 2040 | <p>You can access the current values of these two numbers through the |
| 2045 | following functions: | 2041 | following functions: |
| 2046 | <PRE> | 2042 | <PRE> |
| 2047 | int lua_getgccount (lua_State *L); | 2043 | int lua_getgccount (lua_State *L); |
| 2048 | int lua_getgcthreshold (lua_State *L); | 2044 | int lua_getgcthreshold (lua_State *L); |
| 2049 | </PRE> | 2045 | </PRE> |
| 2050 | | 2046 | |
| @@ -2064,7 +2060,7 @@ In particular · 13 unmodified lines |
| 2064 | After the collection, | 2060 | After the collection, |
| 2065 | a new threshold is set according to the previous rule. | 2061 | a new threshold is set according to the previous rule. |
| 2066 | | 2062 | |
| 2067 | <p><a name="userdata"><h2>3.8 - Userdata</h2></a> | 2063 | <p><a name="userdata"><a name="3.8"><h2>3.8 - Userdata</h2></a></a> |
| 2068 | | 2064 | |
| 2069 | <p>Userdata represents C values in Lua. | 2065 | <p>Userdata represents C values in Lua. |
| 2070 | Lua supports two types of userdata: | 2066 | Lua supports two types of userdata: |
| @@ -2109,7 +2105,7 @@ when applied on a non-userdata value, it returns <code>NULL</code>. · 38 unmodified lines |
| 2109 | it calls the userdata's <code>gc</code> metamethod, if any, | 2105 | it calls the userdata's <code>gc</code> metamethod, if any, |
| 2110 | and then it frees the userdata's corresponding memory. | 2106 | and then it frees the userdata's corresponding memory. |
| 2111 | | 2107 | |
| 2112 | <p><h2>3.9 - Metatables</h2> | 2108 | <p><a name="3.9"><h2>3.9 - Metatables</h2></a> |
| 2113 | | 2109 | |
| 2114 | <p>The following functions allow you to manipulate the metatables | 2110 | <p>The following functions allow you to manipulate the metatables |
| 2115 | of an object: | 2111 | of an object: |
| @@ -2130,7 +2126,7 @@ set the metatable of the given object · 14 unmodified lines |
| 2130 | (that is, when the object is neither a userdata nor a table); | 2126 | (that is, when the object is neither a userdata nor a table); |
| 2131 | even then it pops the table from the stack. | 2127 | even then it pops the table from the stack. |
| 2132 | | 2128 | |
| 2133 | <p><h2>3.10 - Loading Lua Chunks</h2> | 2129 | <p><a name="3.10"><h2>3.10 - Loading Lua Chunks</h2></a> |
| 2134 | | 2130 | |
| 2135 | <p>You can load a Lua chunk with <code>lua_load</code>: | 2131 | <p>You can load a Lua chunk with <code>lua_load</code>: |
| 2136 | <PRE> | 2132 | <PRE> |
| @@ -2157,9 +2153,9 @@ Otherwise, it pushes an error message. · 20 unmodified lines |
| 2157 | <p><code>lua_load</code> automatically detects whether the chunk is text or binary, | 2153 | <p><code>lua_load</code> automatically detects whether the chunk is text or binary, |
| 2158 | and loads it accordingly (see program <code>luac</code>). | 2154 | and loads it accordingly (see program <code>luac</code>). |
| 2159 | | 2155 | |
| 2160 | <p><code>lua_load</code> uses an user-supplied <em>reader</em> function to read the chunk. | 2156 | <p><code>lua_load</code> uses a user-supplied <em>reader</em> function to read the chunk. |
| 2161 | Everytime it needs another piece of the chunk, | 2157 | Everytime it needs another piece of the chunk, |
| 2162 | it calls the reader, | 2158 | <code>lua_load</code> calls the reader, |
| 2163 | passing along its <code>data</code> parameter. | 2159 | passing along its <code>data</code> parameter. |
| 2164 | The reader must return a pointer to a block of memory | 2160 | The reader must return a pointer to a block of memory |
| 2165 | with a new piece of the chunk | 2161 | with a new piece of the chunk |
| @@ -2179,7 +2175,7 @@ for examples of how to use <code>lua_load</code> · 13 unmodified lines |
| 2179 | and for some ready-to-use functions to load chunks | 2175 | and for some ready-to-use functions to load chunks |
| 2180 | from files and strings. | 2176 | from files and strings. |
| 2181 | | 2177 | |
| 2182 | <p><h2>3.11 - Manipulating Tables</h2> | 2178 | <p><a name="3.11"><h2>3.11 - Manipulating Tables</h2></a> |
| 2183 | | 2179 | |
| 2184 | <p>Tables are created by calling | 2180 | <p>Tables are created by calling |
| 2185 | the function | 2181 | the function |
| @@ -2260,7 +2256,7 @@ unless you know that the key is actually a string. · 74 unmodified lines |
| 2260 | Recall that <code>lua_tostring</code> <em>changes</em> the value at the given index; | 2256 | Recall that <code>lua_tostring</code> <em>changes</em> the value at the given index; |
| 2261 | this confuses the next call to <code>lua_next</code>. | 2257 | this confuses the next call to <code>lua_next</code>. |
| 2262 | | 2258 | |
| 2263 | <p><a name="globals"><h2>3.12 - Manipulating Environments</h2></a> | 2259 | <p><a name="globals"><a name="3.12"><h2>3.12 - Manipulating Environments</h2></a></a> |
| 2264 | | 2260 | |
| 2265 | <p>All global variables are kept in ordinary Lua tables, | 2261 | <p>All global variables are kept in ordinary Lua tables, |
| 2266 | called environments. | 2262 | called environments. |
| @@ -2292,7 +2288,7 @@ the new environment for the function at index <code>index</code> in the stack. · 25 unmodified lines |
| 2292 | If the object at the given index is not a Lua function, | 2288 | If the object at the given index is not a Lua function, |
| 2293 | <code>lua_setfenv</code> returns 0. | 2289 | <code>lua_setfenv</code> returns 0. |
| 2294 | | 2290 | |
| 2295 | <p><h2>3.13 - Using Tables as Arrays</h2> | 2291 | <p><a name="3.13"><h2>3.13 - Using Tables as Arrays</h2></a> |
| 2296 | The API has functions that help to use Lua tables as arrays, | 2292 | The API has functions that help to use Lua tables as arrays, |
| 2297 | that is, | 2293 | that is, |
| 2298 | tables indexed by numbers only: | 2294 | tables indexed by numbers only: |
| @@ -2309,7 +2305,7 @@ at stack position <code>index</code>. · 10 unmodified lines |
| 2309 | at stack position <code>index</code> to the value at the top of the stack, | 2305 | at stack position <code>index</code> to the value at the top of the stack, |
| 2310 | removing this value from the stack. | 2306 | removing this value from the stack. |
| 2311 | | 2307 | |
| 2312 | <p><h2>3.14 - Calling Functions</h2> | 2308 | <p><a name="3.14"><h2>3.14 - Calling Functions</h2></a> |
| 2313 | | 2309 | |
| 2314 | <p>Functions defined in Lua | 2310 | <p>Functions defined in Lua |
| 2315 | and C functions registered in Lua | 2311 | and C functions registered in Lua |
| @@ -2364,7 +2360,7 @@ Usually programmers define and use several macros and auxiliary functions · 48 unmodified lines |
| 2364 | that provide higher level access to Lua. | 2360 | that provide higher level access to Lua. |
| 2365 | See the source code of the standard libraries for examples.) | 2361 | See the source code of the standard libraries for examples.) |
| 2366 | | 2362 | |
| 2367 | <p><a name="lua_pcall"><h2>3.15 - Protected Calls</h2></a> | 2363 | <p><a name="lua_pcall"><a name="3.15"><h2>3.15 - Protected Calls</h2></a></a> |
| 2368 | | 2364 | |
| 2369 | <p>When you call a function with <code>lua_call</code>, | 2365 | <p>When you call a function with <code>lua_call</code>, |
| 2370 | any error inside the called function is propagated upwards | 2366 | any error inside the called function is propagated upwards |
| @@ -2411,7 +2407,7 @@ For such errors, Lua does not call the error handler function. · 40 unmodified lines |
| 2411 | error while running the error handler function. | 2407 | error while running the error handler function. |
| 2412 | </ul> | 2408 | </ul> |
| 2413 | | 2409 | |
| 2414 | <p><a name="LuacallC"><h2>3.16 - Defining C Functions</h2></a> | 2410 | <p><a name="LuacallC"><a name="3.16"><h2>3.16 - Defining C Functions</h2></a></a> |
| 2415 | | 2411 | |
| 2416 | <p>Lua can be extended with functions written in C. | 2412 | <p>Lua can be extended with functions written in C. |
| 2417 | These functions must be of type <code>lua_CFunction</code>, | 2413 | These functions must be of type <code>lua_CFunction</code>, |
| @@ -2479,7 +2475,7 @@ the C function <code>foo</code> above may be registered in Lua as · 61 unmodified lines |
| 2479 | lua_register(L, "average", foo); | 2475 | lua_register(L, "average", foo); |
| 2480 | </PRE> | 2476 | </PRE> |
| 2481 | | 2477 | |
| 2482 | <p><a name="c-closure"><h2>3.17 - Defining C Closures</h2></a> | 2478 | <p><a name="c-closure"><a name="3.17"><h2>3.17 - Defining C Closures</h2></a></a> |
| 2483 | | 2479 | |
| 2484 | <p>When a C function is created, | 2480 | <p>When a C function is created, |
| 2485 | it is possible to associate some values with it, | 2481 | it is possible to associate some values with it, |
| @@ -2514,7 +2510,7 @@ produces an acceptable (but invalid) index. · 28 unmodified lines |
| 2514 | see the standard libraries in the official Lua distribution | 2510 | see the standard libraries in the official Lua distribution |
| 2515 | (<code>src/lib/*.c</code>). | 2511 | (<code>src/lib/*.c</code>). |
| 2516 | | 2512 | |
| 2517 | <p><a name="registry"><h2>3.18 - Registry</h2></a> | 2513 | <p><a name="registry"><a name="3.18"><h2>3.18 - Registry</h2></a></a> |
| 2518 | | 2514 | |
| 2519 | <p>Lua provides a registry, | 2515 | <p>Lua provides a registry, |
| 2520 | a pre-defined table that can be used by any C code to | 2516 | a pre-defined table that can be used by any C code to |
| @@ -2532,26 +2528,26 @@ or a light userdata with the address of a C object in your code. · 11 unmodified lines |
| 2532 | implemented by the auxiliary library, | 2528 | implemented by the auxiliary library, |
| 2533 | and therefore should not be used by other purposes. | 2529 | and therefore should not be used by other purposes. |
| 2534 | | 2530 | |
| 2535 | <p><h2>3.19 - Error Handling in C</h2> | 2531 | <p><a name="3.19"><h2>3.19 - Error Handling in C</h2></a> |
| 2536 | | 2532 | |
| 2537 | <p>Internally, Lua uses the C <code>longjmp</code> facility to handle errors. | 2533 | <p>Internally, Lua uses the C <code>longjmp</code> facility to handle errors. |
| 2538 | When Lua faces any error | 2534 | When Lua faces any error |
| 2539 | (such as memory allocation errors, type errors, syntax errors) | 2535 | (such as memory allocation errors, type errors, syntax errors) |
| 2540 | it <em>raises</em> an error, that is, it does a long jump. | 2536 | it <em>raises</em> an error, that is, it does a long jump. |
| 2541 | A <em>protected environment</em> uses <code>setjmp</code> | 2537 | A <em>protected environment</em> uses <code>setjmp</code> |
| 2542 | to set a recover point, | 2538 | to set a recover point; |
| 2543 | and any error jumps to the most recent active recover point. | 2539 | any error jumps to the most recent active recover point. |
| 2544 | | 2540 | |
| 2545 | <p>If an error happens outside any protected environment, | 2541 | <p>If an error happens outside any protected environment, |
| 2546 | Lua calls a <em>panic function</em>, | 2542 | Lua calls a <em>panic function</em> |
| 2547 | and then calls <code>exit(EXIT_FAILURE)</code>. | 2543 | and then calls <code>exit(EXIT_FAILURE)</code>. |
| 2548 | You can change the panic function with | 2544 | You can change the panic function with |
| 2549 | <PRE> | 2545 | <PRE> |
| 2550 | lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf); | 2546 | lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf); |
| 2551 | </PRE> | 2547 | </PRE> |
| 2552 | Your new panic function may avoid the application exit by | 2548 | Your new panic function may avoid the application exit by |
| 2553 | never returning (e.g. doing a long jump). | 2549 | never returning (e.g., by doing a long jump). |
| 2554 | Nevertheless, the corresponding Lua will not be consistent; | 2550 | Nevertheless, the corresponding Lua state will not be consistent; |
| 2555 | the only safe operation with it is to close it. | 2551 | the only safe operation with it is to close it. |
| 2556 | | 2552 | |
| 2557 | <p>Almost any function in the API may raise an error, | 2553 | <p>Almost any function in the API may raise an error, |
| @@ -2575,7 +2571,7 @@ In case of errors, · 17 unmodified lines |
| 2575 | (see <a href="#lua_pcall">3.15</a>), | 2571 | (see <a href="#lua_pcall">3.15</a>), |
| 2576 | plus the error object on the top of the stack; | 2572 | plus the error object on the top of the stack; |
| 2577 | otherwise, it returns zero, and does not change the stack. | 2573 | otherwise, it returns zero, and does not change the stack. |
| 2578 | Any value returned by <code>func</code> is dicarded. | 2574 | Any value returned by <code>func</code> is discarded. |
| 2579 | | 2575 | |
| 2580 | <p>C code can generate a Lua error calling the function | 2576 | <p>C code can generate a Lua error calling the function |
| 2581 | <PRE> | 2577 | <PRE> |
| @@ -2587,7 +2583,7 @@ must be on the stack top. · 5 unmodified lines |
| 2587 | This function does a long jump, | 2583 | This function does a long jump, |
| 2588 | and therefore never returns. | 2584 | and therefore never returns. |
| 2589 | | 2585 | |
| 2590 | <p><h2>3.20 - Threads</h2> | 2586 | <p><a name="3.20"><h2>3.20 - Threads</h2></a> |
| 2591 | | 2587 | |
| 2592 | <p>Lua offers partial support for multiple threads of execution. | 2588 | <p>Lua offers partial support for multiple threads of execution. |
| 2593 | If you have a C library that offers multi-threading, | 2589 | If you have a C library that offers multi-threading, |
| @@ -2608,18 +2604,15 @@ but has an independent run-time stack. · 14 unmodified lines |
| 2608 | When you create a thread, this table is the same as that of the given state, | 2604 | When you create a thread, this table is the same as that of the given state, |
| 2609 | but you can change each one independently. | 2605 | but you can change each one independently. |
| 2610 | | 2606 | |
| 2611 | <p>You destroy threads with <code>lua_closethread</code>: | 2607 | <p>There is no explicit function to close or to destroy a thread. |
| 2612 | <PRE> | 2608 | Threads are subject to garbage collection, |
| 2613 | void lua_closethread (lua_State *L, lua_State *thread); | 2609 | like any Lua object. |
| 2614 | </PRE> | | |
| 2615 | You cannot close the sole (or last) thread of a state. | | |
| 2616 | Instead, you must close the state itself. | | |
| 2617 | | 2610 | |
| 2618 | <p>To manipulate threads as coroutines, | 2611 | <p>To manipulate threads as coroutines, |
| 2619 | Lua offers the following functions: | 2612 | Lua offers the following functions: |
| 2620 | <PRE> | 2613 | <PRE> |
| 2621 | int lua_resume (lua_State *L, int narg); | 2614 | int lua_resume (lua_State *L, int narg); |
| 2622 | int lua_yield (lua_State *L, int nresults); | 2615 | int lua_yield (lua_State *L, int nresults); |
| 2623 | </PRE> | 2616 | </PRE> |
| 2624 | | 2617 | |
| 2625 | To start a coroutine, you first create a new thread; | 2618 | To start a coroutine, you first create a new thread; |
| @@ -2629,7 +2622,7 @@ with <code>narg</code> being the number of arguments. · 3 unmodified lines |
| 2629 | This call returns when the coroutine suspends or finishes its execution. | 2622 | This call returns when the coroutine suspends or finishes its execution. |
| 2630 | When it returns, the stack contains all values passed to <code>lua_yield</code>, | 2623 | When it returns, the stack contains all values passed to <code>lua_yield</code>, |
| 2631 | or all values returned by the body function. | 2624 | or all values returned by the body function. |
| 2632 | <code>lua_resume</code> returns 0 if there is no errors running the coroutine, | 2625 | <code>lua_resume</code> returns 0 if there are no errors running the coroutine, |
| 2633 | or an error code (see <a href="#lua_pcall">3.15</a>). | 2626 | or an error code (see <a href="#lua_pcall">3.15</a>). |
| 2634 | In case of errors, | 2627 | In case of errors, |
| 2635 | the stack contains only the error message. | 2628 | the stack contains only the error message. |
| @@ -2657,7 +2650,7 @@ It pops <code>n</code> values from the stack <code>from</code>, · 21 unmodified lines |
| 2657 | and puhses them into the stack <code>to</code>. | 2650 | and puhses them into the stack <code>to</code>. |
| 2658 | | 2651 | |
| 2659 | <p> | 2652 | <p> |
| 2660 | <a name="debugI"><h1>4 - The Debug Interface</h1></a> | 2653 | <a name="debugI"><a name="4"><h1>4 - The Debug Interface</h1></a></a> |
| 2661 | | 2654 | |
| 2662 | <p>Lua has no built-in debugging facilities. | 2655 | <p>Lua has no built-in debugging facilities. |
| 2663 | Instead, it offers a special interface | 2656 | Instead, it offers a special interface |
| @@ -2666,7 +2659,7 @@ This interface allows the construction of different · 2 unmodified lines |
| 2666 | kinds of debuggers, profilers, and other tools | 2659 | kinds of debuggers, profilers, and other tools |
| 2667 | that need "inside information" from the interpreter. | 2660 | that need "inside information" from the interpreter. |
| 2668 | | 2661 | |
| 2669 | <p><h2>4.1 - Stack and Function Information</h2> | 2662 | <p><a name="4.1"><h2>4.1 - Stack and Function Information</h2></a> |
| 2670 | | 2663 | |
| 2671 | <p>The main function to get information about the interpreter runtime stack is | 2664 | <p>The main function to get information about the interpreter runtime stack is |
| 2672 | <PRE> | 2665 | <PRE> |
| @@ -2678,7 +2671,7 @@ an identification of the <em>activation record</em> · 5 unmodified lines |
| 2678 | of the function executing at a given level. | 2671 | of the function executing at a given level. |
| 2679 | Level 0 is the current running function, | 2672 | Level 0 is the current running function, |
| 2680 | whereas level <em>n+1</em> is the function that has called level <em>n</em>. | 2673 | whereas level <em>n+1</em> is the function that has called level <em>n</em>. |
| 2681 | When there is no errors, <code>lua_getstack</code> returns 1; | 2674 | When there are no errors, <code>lua_getstack</code> returns 1; |
| 2682 | when called with a level greater than the stack depth, | 2675 | when called with a level greater than the stack depth, |
| 2683 | it returns 0. | 2676 | it returns 0. |
| 2684 | | 2677 | |
| @@ -2786,7 +2779,7 @@ The number of upvalues of the function. · 101 unmodified lines |
| 2786 | | 2779 | |
| 2787 | <p></ul> | 2780 | <p></ul> |
| 2788 | | 2781 | |
| 2789 | <p><h2>4.2 - Manipulating Local Variables and Upvalues</h2> | 2782 | <p><a name="4.2"><h2>4.2 - Manipulating Local Variables and Upvalues</h2></a> |
| 2790 | | 2783 | |
| 2791 | <p>For the manipulation of local variables and upvalues, | 2784 | <p>For the manipulation of local variables and upvalues, |
| 2792 | the debug interface uses indices: | 2785 | the debug interface uses indices: |
| @@ -2863,7 +2856,7 @@ local variables and upvalues for a function at a given level of the stack: · 70 unmodified lines |
| 2863 | } | 2856 | } |
| 2864 | </PRE> | 2857 | </PRE> |
| 2865 | | 2858 | |
| 2866 | <p><a name="sub-hooks"><h2>4.3 - Hooks</h2></a> | 2859 | <p><a name="sub-hooks"><a name="4.3"><h2>4.3 - Hooks</h2></a></a> |
| 2867 | | 2860 | |
| 2868 | <p>Lua offers a mechanism of hooks, which are | 2861 | <p>Lua offers a mechanism of hooks, which are |
| 2869 | user-defined C functions that are called during the program execution. | 2862 | user-defined C functions that are called during the program execution. |
| @@ -2939,7 +2932,7 @@ Therefore, if a hook calls back Lua to execute a function or a chunk, · 69 unmodified lines |
| 2939 | that execution occurs without any calls to hooks. | 2932 | that execution occurs without any calls to hooks. |
| 2940 | | 2933 | |
| 2941 | <p> | 2934 | <p> |
| 2942 | <a name="libraries"><h1>5 - Standard Libraries</h1></a> | 2935 | <a name="libraries"><a name="5"><h1>5 - Standard Libraries</h1></a></a> |
| 2943 | | 2936 | |
| 2944 | <p>The standard libraries provide useful functions | 2937 | <p>The standard libraries provide useful functions |
| 2945 | that are implemented directly through the C API. | 2938 | that are implemented directly through the C API. |
| @@ -2982,7 +2975,7 @@ These functions are declared in <code>lualib.h</code>. · 36 unmodified lines |
| 2982 | | 2975 | |
| 2983 | | 2976 | |
| 2984 | | 2977 | |
| 2985 | <p><a name="predefined"><h2>5.1 - Basic Functions</h2></a> | 2978 | <p><a name="predefined"><a name="5.1"><h2>5.1 - Basic Functions</h2></a></a> |
| 2986 | | 2979 | |
| 2987 | <p>The basic library provides some core functions to Lua. | 2980 | <p>The basic library provides some core functions to Lua. |
| 2988 | If you do not include this library in your application, | 2981 | If you do not include this library in your application, |
| @@ -3015,7 +3008,7 @@ to its caller (that is, it does not run in protected mode). · 26 unmodified lines |
| 3015 | | 3008 | |
| 3016 | <p><a name="pdf-error"><h3><code>error (message [, level])</code></h3></a> | 3009 | <p><a name="pdf-error"><h3><code>error (message [, level])</code></h3></a> |
| 3017 | | 3010 | |
| 3018 | Terminates the last protected function called, | 3011 | Terminates the last protected function called |
| 3019 | and returns <code>message</code> as the error message. | 3012 | and returns <code>message</code> as the error message. |
| 3020 | Function <code>error</code> never returns. | 3013 | Function <code>error</code> never returns. |
| 3021 | | 3014 | |
| @@ -3043,7 +3036,7 @@ or if <code>f</code> is 0, · 21 unmodified lines |
| 3043 | <code>getfenv</code> returns the global environment. | 3036 | <code>getfenv</code> returns the global environment. |
| 3044 | The default for <code>f</code> is 1. | 3037 | The default for <code>f</code> is 1. |
| 3045 | | 3038 | |
| 3046 | <p>if the environment has a <code>"__fenv"</code> field, | 3039 | <p>If the environment has a <code>"__fenv"</code> field, |
| 3047 | returns the associated value, instead of the environment. | 3040 | returns the associated value, instead of the environment. |
| 3048 | | 3041 | |
| 3049 | <p><a name="pdf-getmetatable"><h3><code>getmetatable (object)</code></h3></a> | 3042 | <p><a name="pdf-getmetatable"><h3><code>getmetatable (object)</code></h3></a> |
| @@ -3148,11 +3141,11 @@ will iterate over all key-value pairs of table <code>t</code>. · 98 unmodified lines |
| 3148 | | 3141 | |
| 3149 | <p>Calls function <code>f</code> with | 3142 | <p>Calls function <code>f</code> with |
| 3150 | the given arguments in protected mode. | 3143 | the given arguments in protected mode. |
| 3151 | That means that any error inside <code>f</code> is not propagated; | 3144 | That means that any error inside <code>f</code> is not propagated; |
| 3152 | instead, <code>pcall</code> catches the error | 3145 | instead, <code>pcall</code> catches the error |
| 3153 | and returns a status code. | 3146 | and returns a status code. |
| 3154 | Its first result is the status code (a boolean), | 3147 | Its first result is the status code (a boolean), |
| 3155 | which is true if the call succeeds without errors. | 3148 | which is <B>true</B> if the call succeeds without errors. |
| 3156 | In such case, <code>pcall</code> also returns all results from the call, | 3149 | In such case, <code>pcall</code> also returns all results from the call, |
| 3157 | after this first result. | 3150 | after this first result. |
| 3158 | In case of any error, <code>pcall</code> returns <B>false</B> plus the error message. | 3151 | In case of any error, <code>pcall</code> returns <B>false</B> plus the error message. |
| @@ -3327,10 +3320,10 @@ after this first result. · 168 unmodified lines |
| 3327 | In case of any error, | 3320 | In case of any error, |
| 3328 | <code>xpcall</code> returns false plus the result from <code>err</code>. | 3321 | <code>xpcall</code> returns false plus the result from <code>err</code>. |
| 3329 | | 3322 | |
| 3330 | <p><h2>5.2 - Coroutine Manipulation</h2> | 3323 | <p><a name="5.2"><h2>5.2 - Coroutine Manipulation</h2></a> |
| 3331 | | 3324 | |
| 3332 | <p>The operations related to coroutines comprise a sub-library of | 3325 | <p>The operations related to coroutines comprise a sub-library of |
| 3333 | the basic library, and come inside the table . | 3326 | the basic library and come inside the table <code>coroutine</code>. |
| 3334 | See <a href="#coroutine">2.10</a> for a general description of coroutines. | 3327 | See <a href="#coroutine">2.10</a> for a general description of coroutines. |
| 3335 | | 3328 | |
| 3336 | <p><h3><code>coroutine.create (f)</code></h3> | 3329 | <p><h3><code>coroutine.create (f)</code></h3> |
| @@ -3385,7 +3378,7 @@ The coroutine cannot be running neither a C function, · 48 unmodified lines |
| 3385 | nor a metamethod, nor an iterator. | 3378 | nor a metamethod, nor an iterator. |
| 3386 | Any arguments to <code>yield</code> go as extra results to <code>resume</code>. | 3379 | Any arguments to <code>yield</code> go as extra results to <code>resume</code>. |
| 3387 | | 3380 | |
| 3388 | <p><h2>5.3 - String Manipulation</h2> | 3381 | <p><a name="5.3"><h2>5.3 - String Manipulation</h2></a> |
| 3389 | This library provides generic functions for string manipulation, | 3382 | This library provides generic functions for string manipulation, |
| 3390 | such as finding and extracting substrings, and pattern matching. | 3383 | such as finding and extracting substrings, and pattern matching. |
| 3391 | When indexing a string in Lua, the first character is at position 1 | 3384 | When indexing a string in Lua, the first character is at position 1 |
| @@ -3592,7 +3585,7 @@ For instance, when <code>n</code> is 1 only the first occurrence of · 200 unmodified lines |
| 3592 | <p><a name="pm"><h3>Patterns</h3></a> | 3585 | <p><a name="pm"><h3>Patterns</h3></a> |
| 3593 | | 3586 | |
| 3594 | <p><p> | 3587 | <p><p> |
| 3595 | a <em>character class</em> is used to represent a set of characters. | 3588 | A <em>character class</em> is used to represent a set of characters. |
| 3596 | The following combinations are allowed in describing a character class: | 3589 | The following combinations are allowed in describing a character class: |
| 3597 | <ul> | 3590 | <ul> |
| 3598 | <li><b><em>x</em></b> (where <em>x</em> is not one of the magic characters | 3591 | <li><b><em>x</em></b> (where <em>x</em> is not one of the magic characters |
| @@ -3648,7 +3641,7 @@ In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</c · 49 unmodified lines |
| 3648 | The second form should be preferred for portability. | 3641 | The second form should be preferred for portability. |
| 3649 | | 3642 | |
| 3650 | <p><p> | 3643 | <p><p> |
| 3651 | a <em>pattern item</em> may be | 3644 | A <em>pattern item</em> may be |
| 3652 | <ul> | 3645 | <ul> |
| 3653 | <li> | 3646 | <li> |
| 3654 | a single character class, | 3647 | a single character class, |
| @@ -3685,7 +3678,7 @@ balanced parentheses. · 30 unmodified lines |
| 3685 | </ul> | 3678 | </ul> |
| 3686 | | 3679 | |
| 3687 | <p><p> | 3680 | <p><p> |
| 3688 | a <em>pattern</em> is a sequence of pattern items. | 3681 | A <em>pattern</em> is a sequence of pattern items. |
| 3689 | A `<code>^</code>´ at the beginning of a pattern anchors the match at the | 3682 | A `<code>^</code>´ at the beginning of a pattern anchors the match at the |
| 3690 | beginning of the subject string. | 3683 | beginning of the subject string. |
| 3691 | A `<code>$</code>´ at the end of a pattern anchors the match at the | 3684 | A `<code>$</code>´ at the end of a pattern anchors the match at the |
| @@ -3712,7 +3705,7 @@ string <code>"flaaap"</code>, there will be two captures: 3 and 5. · 20 unmodified lines |
| 3712 | | 3705 | |
| 3713 | <p>A pattern cannot contain embedded zeros. Use <code>%z</code> instead. | 3706 | <p>A pattern cannot contain embedded zeros. Use <code>%z</code> instead. |
| 3714 | | 3707 | |
| 3715 | <p><h2>5.4 - Table Manipulation</h2> | 3708 | <p><a name="5.4"><h2>5.4 - Table Manipulation</h2></a> |
| 3716 | This library provides generic functions for table manipulation. | 3709 | This library provides generic functions for table manipulation. |
| 3717 | It provides all its functions inside the table <code>table</code>. | 3710 | It provides all its functions inside the table <code>table</code>. |
| 3718 | | 3711 | |
| @@ -3821,7 +3814,7 @@ that value is changed to the given <code>n</code>. · 102 unmodified lines |
| 3821 | Otherwise, it updates an internal state | 3814 | Otherwise, it updates an internal state |
| 3822 | so that subsequent calls to <code>table.getn(table)</code> return <code>n</code>. | 3815 | so that subsequent calls to <code>table.getn(table)</code> return <code>n</code>. |
| 3823 | | 3816 | |
| 3824 | <p><a name="mathlib"><h2>5.5 - Mathematical Functions</h2></a> | 3817 | <p><a name="mathlib"><a name="5.5"><h2>5.5 - Mathematical Functions</h2></a></a> |
| 3825 | | 3818 | |
| 3826 | <p>This library is an interface to most of the functions of the | 3819 | <p>This library is an interface to most of the functions of the |
| 3827 | standard C math library. | 3820 | standard C math library. |
| @@ -3876,7 +3869,7 @@ The <code>math.randomseed</code> function sets a "seed" · 48 unmodified lines |
| 3876 | for the pseudo-random generator: | 3869 | for the pseudo-random generator: |
| 3877 | Equal seeds produce equal sequences of numbers. | 3870 | Equal seeds produce equal sequences of numbers. |
| 3878 | | 3871 | |
| 3879 | <p><a name="libio"><h2>5.6 - Input and Output Facilities</h2></a> | 3872 | <p><a name="libio"><a name="5.6"><h2>5.6 - Input and Output Facilities</h2></a></a> |
| 3880 | | 3873 | |
| 3881 | <p>The I/O library provides two different styles for file manipulation. | 3874 | <p>The I/O library provides two different styles for file manipulation. |
| 3882 | The first one uses implicit file descriptors, | 3875 | The first one uses implicit file descriptors, |
| @@ -4069,7 +4062,7 @@ The arguments must be strings or numbers. · 186 unmodified lines |
| 4069 | To write other values, | 4062 | To write other values, |
| 4070 | use <code>tostring</code> or <code>string.format</code> before <code>write</code>. | 4063 | use <code>tostring</code> or <code>string.format</code> before <code>write</code>. |
| 4071 | | 4064 | |
| 4072 | <p><a name="libiosys"><h2>5.7 - Operating System Facilities</h2></a> | 4065 | <p><a name="libiosys"><a name="5.7"><h2>5.7 - Operating System Facilities</h2></a></a> |
| 4073 | | 4066 | |
| 4074 | <p>This library is implemented through table <code>os</code>. | 4067 | <p>This library is implemented through table <code>os</code>. |
| 4075 | | 4068 | |
| @@ -4095,7 +4088,7 @@ if <code>format</code> is <code>*t</code>, · 19 unmodified lines |
| 4095 | then <code>date</code> returns a table with the following fields: | 4088 | then <code>date</code> returns a table with the following fields: |
| 4096 | <code>year</code> (four digits), <code>month</code> (1--12), <code>day</code> (1--31), | 4089 | <code>year</code> (four digits), <code>month</code> (1--12), <code>day</code> (1--31), |
| 4097 | <code>hour</code> (0--23), <code>min</code> (0--59), <code>sec</code> (0--61), | 4090 | <code>hour</code> (0--23), <code>min</code> (0--59), <code>sec</code> (0--61), |
| 4098 | <code>wday</code> (weekday, Sunday is 1), | 4091 | <code>wday</code> (weekday, Sunday is 1), |
| 4099 | <code>yday</code> (day of the year), | 4092 | <code>yday</code> (day of the year), |
| 4100 | and <code>isdst</code> (daylight saving flag, a boolean). | 4093 | and <code>isdst</code> (daylight saving flag, a boolean). |
| 4101 | | 4094 | |
| @@ -4184,7 +4177,7 @@ and the time you open the file, · 82 unmodified lines |
| 4184 | it is possible for another process | 4177 | it is possible for another process |
| 4185 | to create a file with the same name. | 4178 | to create a file with the same name. |
| 4186 | | 4179 | |
| 4187 | <p><h2>5.8 - The Reflexive Debug Interface</h2> | 4180 | <p><a name="5.8"><h2>5.8 - The Reflexive Debug Interface</h2></a> |
| 4188 | | 4181 | |
| 4189 | <p>The <code>debug</code> library provides | 4182 | <p>The <code>debug</code> library provides |
| 4190 | the functionality of the debug interface to Lua programs. | 4183 | the functionality of the debug interface to Lua programs. |
| @@ -4320,7 +4313,7 @@ This function is typically used with <code>xpcall</code> to produce · 129 unmodified lines |
| 4320 | better error messages. | 4313 | better error messages. |
| 4321 | | 4314 | |
| 4322 | <p> | 4315 | <p> |
| 4323 | <a name="lua-sa"><h1>6 - Lua Stand-alone</h1></a> | 4316 | <a name="lua-sa"><a name="6"><h1>6 - Lua Stand-alone</h1></a></a> |
| 4324 | | 4317 | |
| 4325 | <p>Although Lua has been designed as an extension language, | 4318 | <p>Although Lua has been designed as an extension language, |
| 4326 | to be embedded in a host C program, | 4319 | to be embedded in a host C program, |
| @@ -4459,7 +4452,7 @@ Stephan Herrmann, · 132 unmodified lines |
| 4459 | Steve Dekorte, | 4452 | Steve Dekorte, |
| 4460 | Thatcher Ulrich, | 4453 | Thatcher Ulrich, |
| 4461 | Tomás Gorham, | 4454 | Tomás Gorham, |
| 4462 | Vincent Penquerc'h, | 4455 | Vincent Penquerc'h. |
| 4463 | Thank you! | 4456 | Thank you! |
| 4464 | | 4457 | |
| 4465 | <p><hr> | 4458 | <p><hr> |
| @@ -4580,7 +4573,7 @@ Use <code>lua_newuserdata</code> or <code>lua_pushlightuserdata</code> instead. · 114 unmodified lines |
| 4580 | | 4573 | |
| 4581 | <p> explist1 ::= {exp `<b>,</b>´} exp | 4574 | <p> explist1 ::= {exp `<b>,</b>´} exp |
| 4582 | | 4575 | |
| 4583 | <p> exp ::= <b>nil</b> <b>false</b> <b>true</b> | Number | Literal | function | prefixexp | tableconstructor | exp binop exp | unop exp | 4576 | <p> exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | Literal | function | prefixexp | tableconstructor | exp binop exp | unop exp |
| 4584 | | 4577 | |
| 4585 | <p> prefixexp ::= var | functioncall | `<b>(</b>´ exp `<b>)</b>´ | 4578 | <p> prefixexp ::= var | functioncall | `<b>(</b>´ exp `<b>)</b>´ |
| 4586 | | 4579 | |
| @@ -4609,5 +4602,11 @@ Use <code>lua_newuserdata</code> or <code>lua_pushlightuserdata</code> instead. · 22 unmodified lines |
| 4609 | | 4602 | |
| 4610 | <p> | 4603 | <p> |
| 4611 | | 4604 | |
| 4612 | </body></html> | 4605 | <HR> |
| | 4606 | <SMALL> |
| | 4607 | Last update: |
| | 4608 | Tue Nov 25 16:08:37 BRST 2003 |
| | 4609 | </SMALL> |
| 4613 | | 4610 | |
| | 4611 | </BODY> |
| | 4612 | </HTML> |