| @@ -38,7 +38,7 @@ Freely available under the terms of the · 37 unmodified lines |
| 38 | 38 | <!-- ====================================================================== --> |
| 39 | 39 | <p> |
| 40 | 40 | |
| 41 | | −<!-- $Id: manual.of,v 1.79 2011/06/21 14:35:46 roberto Exp $ --> |
| 41 | +<!-- $Id: manual.of,v 1.80 2011/06/27 18:26:28 roberto Exp $ --> |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | |
| @@ -209,10 +209,11 @@ Thus tables can also carry <em>methods</em> (see <a href="#3.4.10">§3.4.10< · 164 unmodified lines |
| 209 | 209 | |
| 210 | 210 | <p> |
| 211 | 211 | The indexing of tables follows |
| 212 | | −the definition of equality in the language. |
| 212 | +the definition of raw equality in the language. |
| 213 | 213 | The expressions <code>a[i]</code> and <code>a[j]</code> |
| 214 | 214 | denote the same table element |
| 215 | | −if and only if <code>i == j</code>. |
| 215 | +if and only if <code>i</code> and <code>j</code> are raw equal |
| 216 | +(that is, equal without metamethods). |
| 216 | 217 | |
| 217 | 218 | |
| 218 | 219 | <p> |
| @@ -328,7 +329,7 @@ you may give an <em>message handler</em> · 109 unmodified lines |
| 328 | 329 | to be called in case of errors. |
| 329 | 330 | This function is called with the original error message |
| 330 | 331 | and returns a new error message. |
| 331 | | −It is called before the error unwonds the stack, |
| 332 | +It is called before the error unwinds the stack, |
| 332 | 333 | so that it can gather more information about the error, |
| 333 | 334 | for instance by inspecting the stack and creating a stack traceback. |
| 334 | 335 | This message handler is still protected by the protected call; |
| @@ -443,7 +444,7 @@ in the following code. · 108 unmodified lines |
| 443 | 444 | |
| 444 | 445 | <ul> |
| 445 | 446 | |
| 446 | | −<li><b>"add":</b> |
| 447 | +<li><b>"add": </b> |
| 447 | 448 | the <code>+</code> operation. |
| 448 | 449 | |
| 449 | 450 | |
| @@ -481,25 +482,25 @@ the behavior of the <code>op1 + op2</code> is · 31 unmodified lines |
| 481 | 482 | </pre><p> |
| 482 | 483 | </li> |
| 483 | 484 | |
| 484 | | −<li><b>"sub":</b> |
| 485 | +<li><b>"sub": </b> |
| 485 | 486 | the <code>-</code> operation. |
| 486 | 487 | |
| 487 | 488 | Behavior similar to the "add" operation. |
| 488 | 489 | </li> |
| 489 | 490 | |
| 490 | | −<li><b>"mul":</b> |
| 491 | +<li><b>"mul": </b> |
| 491 | 492 | the <code>*</code> operation. |
| 492 | 493 | |
| 493 | 494 | Behavior similar to the "add" operation. |
| 494 | 495 | </li> |
| 495 | 496 | |
| 496 | | −<li><b>"div":</b> |
| 497 | +<li><b>"div": </b> |
| 497 | 498 | the <code>/</code> operation. |
| 498 | 499 | |
| 499 | 500 | Behavior similar to the "add" operation. |
| 500 | 501 | </li> |
| 501 | 502 | |
| 502 | | −<li><b>"mod":</b> |
| 503 | +<li><b>"mod": </b> |
| 503 | 504 | the <code>%</code> operation. |
| 504 | 505 | |
| 505 | 506 | Behavior similar to the "add" operation, |
| @@ -507,7 +508,7 @@ with the operation · 1 unmodified line |
| 507 | 508 | <code>o1 - floor(o1/o2)*o2</code> as the primitive operation. |
| 508 | 509 | </li> |
| 509 | 510 | |
| 510 | | −<li><b>"pow":</b> |
| 511 | +<li><b>"pow": </b> |
| 511 | 512 | the <code>^</code> (exponentiation) operation. |
| 512 | 513 | |
| 513 | 514 | Behavior similar to the "add" operation, |
| @@ -515,7 +516,7 @@ with the function <code>pow</code> (from the C math library) · 1 unmodified line |
| 515 | 516 | as the primitive operation. |
| 516 | 517 | </li> |
| 517 | 518 | |
| 518 | | −<li><b>"unm":</b> |
| 519 | +<li><b>"unm": </b> |
| 519 | 520 | the unary <code>-</code> operation. |
| 520 | 521 | |
| 521 | 522 | |
| @@ -538,7 +539,7 @@ the unary <code>-</code> operation. · 16 unmodified lines |
| 538 | 539 | </pre><p> |
| 539 | 540 | </li> |
| 540 | 541 | |
| 541 | | −<li><b>"concat":</b> |
| 542 | +<li><b>"concat": </b> |
| 542 | 543 | the <code>..</code> (concatenation) operation. |
| 543 | 544 | |
| 544 | 545 | |
| @@ -559,7 +560,7 @@ the <code>..</code> (concatenation) operation. · 14 unmodified lines |
| 559 | 560 | </pre><p> |
| 560 | 561 | </li> |
| 561 | 562 | |
| 562 | | −<li><b>"len":</b> |
| 563 | +<li><b>"len": </b> |
| 563 | 564 | the <code>#</code> operation. |
| 564 | 565 | |
| 565 | 566 | |
| @@ -582,7 +583,7 @@ the <code>#</code> operation. · 16 unmodified lines |
| 582 | 583 | See <a href="#3.4.6">§3.4.6</a> for a description of the length of a table. |
| 583 | 584 | </li> |
| 584 | 585 | |
| 585 | | −<li><b>"eq":</b> |
| 586 | +<li><b>"eq": </b> |
| 586 | 587 | the <code>==</code> operation. |
| 587 | 588 | |
| 588 | 589 | The function <code>getequalhandler</code> defines how Lua chooses a metamethod |
| @@ -620,7 +621,7 @@ The "eq" event is defined as follows: · 31 unmodified lines |
| 620 | 621 | </pre><p> |
| 621 | 622 | </li> |
| 622 | 623 | |
| 623 | | −<li><b>"lt":</b> |
| 624 | +<li><b>"lt": </b> |
| 624 | 625 | the <code><</code> operation. |
| 625 | 626 | |
| 626 | 627 | |
| @@ -642,7 +643,7 @@ the <code><</code> operation. · 15 unmodified lines |
| 642 | 643 | </pre><p> |
| 643 | 644 | </li> |
| 644 | 645 | |
| 645 | | −<li><b>"le":</b> |
| 646 | +<li><b>"le": </b> |
| 646 | 647 | the <code><=</code> operation. |
| 647 | 648 | |
| 648 | 649 | |
| @@ -672,7 +673,7 @@ Lua tries the "lt", assuming that <code>a <= b</code> is · 23 unmodified lines |
| 672 | 673 | equivalent to <code>not (b < a)</code>. |
| 673 | 674 | </li> |
| 674 | 675 | |
| 675 | | −<li><b>"index":</b> |
| 676 | +<li><b>"index": </b> |
| 676 | 677 | The indexing access <code>table[key]</code>. |
| 677 | 678 | Note that the metamethod is tried only |
| 678 | 679 | when <code>key</code> is not present in <code>table</code>. |
| @@ -704,7 +705,7 @@ so the metamethod is always tried.) · 25 unmodified lines |
| 704 | 705 | </pre><p> |
| 705 | 706 | </li> |
| 706 | 707 | |
| 707 | | −<li><b>"newindex":</b> |
| 708 | +<li><b>"newindex": </b> |
| 708 | 709 | The indexing assignment <code>table[key] = value</code>. |
| 709 | 710 | Note that the metamethod is tried only |
| 710 | 711 | when <code>key</code> is not present in <code>table</code>. |
| @@ -733,7 +734,7 @@ when <code>key</code> is not present in <code>table</code>. · 22 unmodified lines |
| 733 | 734 | </pre><p> |
| 734 | 735 | </li> |
| 735 | 736 | |
| 736 | | −<li><b>"call":</b> |
| 737 | +<li><b>"call": </b> |
| 737 | 738 | called when Lua calls a value. |
| 738 | 739 | |
| 739 | 740 | |
| @@ -845,7 +846,7 @@ and the metatable has a field indexed by the string "<code>__gc</code>". · 105 unmodified lines |
| 845 | 846 | Note that if you set a metatable without a <code>__gc</code> field |
| 846 | 847 | and later create that field in the metatable, |
| 847 | 848 | the object will not be marked for finalization. |
| 848 | | −However, after a userdata is marked, |
| 849 | +However, after an object is marked, |
| 849 | 850 | you can freely change the <code>__gc</code> field of its metatable. |
| 850 | 851 | |
| 851 | 852 | |
| @@ -873,7 +874,16 @@ the reverse order that they were marked for collection, · 21 unmodified lines |
| 873 | 874 | among those collected in that cycle; |
| 874 | 875 | that is, the first finalizer to be called is the one associated |
| 875 | 876 | with the object marked last in the program. |
| 876 | | −The object memory is freed only in the next garbage-collection cycle. |
| 877 | +The execution of each finalizer may occur at any point during |
| 878 | +the execution of the regular code. |
| 879 | + |
| 880 | + |
| 881 | +<p> |
| 882 | +Because the object being collected must still be used by the finalizer |
| 883 | +and even <em>resurrected</em>resurrection |
| 884 | +(e.g., stored by the finalizer in a global variable), |
| 885 | +the object memory is freed only when it becomes completely inaccessible |
| 886 | +(that is, in the next garbage-collection cycle unless it was resurrected). |
| 877 | 887 | |
| 878 | 888 | |
| 879 | 889 | |
| @@ -1536,9 +1546,10 @@ labels in Lua are considered statements too: · 656 unmodified lines |
| 1536 | 1546 | </pre> |
| 1537 | 1547 | |
| 1538 | 1548 | <p> |
| 1539 | | −A label is visible in the entire block where it is defined |
| 1540 | | −(including nested blocks, but not nested functions). |
| 1541 | | −A function cannot have more than one label with a given name. |
| 1549 | +A label is visible in the entire block where it is defined, |
| 1550 | +except |
| 1551 | +inside nested blocks where a label with the same name is defined and |
| 1552 | +inside nested functions. |
| 1542 | 1553 | A goto may jump to any visible label as long as it does not |
| 1543 | 1554 | enter into the scope of a local variable. |
| 1544 | 1555 | |
| @@ -2592,12 +2603,12 @@ defined as constants in <code>lua.h</code>. · 1047 unmodified lines |
| 2592 | 2603 | The following constants are defined: |
| 2593 | 2604 | |
| 2594 | 2605 | <ul> |
| 2595 | | −<li><b>LUA_RIDX_MAINTHREAD:</b> At this index the registry has |
| 2606 | +<li><b>LUA_RIDX_MAINTHREAD: </b> At this index the registry has |
| 2596 | 2607 | the main thread of the state. |
| 2597 | 2608 | (The main thread is the one created together with the state.) |
| 2598 | 2609 | </li> |
| 2599 | 2610 | |
| 2600 | | −<li><b>LUA_RIDX_GLOBALS:</b> At this index the registry has |
| 2611 | +<li><b>LUA_RIDX_GLOBALS: </b> At this index the registry has |
| 2601 | 2612 | the global environment. |
| 2602 | 2613 | This is the C equivalent to the <a href="#pdf-_G"><code>_G</code></a> global variable. |
| 2603 | 2614 | </li> |
| @@ -2840,7 +2851,7 @@ but it seems a safe assumption. · 236 unmodified lines |
| 2840 | 2851 | |
| 2841 | 2852 | |
| 2842 | 2853 | <hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p> |
| 2843 | | −<span class="apii">[-(2/1), +1, <em>e</em>]</span> |
| 2854 | +<span class="apii">[-(2|1), +1, <em>e</em>]</span> |
| 2844 | 2855 | <pre>int lua_arith (lua_State *L, int op);</pre> |
| 2845 | 2856 | |
| 2846 | 2857 | <p> |
| @@ -2858,13 +2869,13 @@ The value of <code>op</code> must be one of the following constants: · 11 unmodified lines |
| 2858 | 2869 | |
| 2859 | 2870 | <ul> |
| 2860 | 2871 | |
| 2861 | | −<li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>:</b>performs addition (<code>+</code>)</li> |
| 2862 | | −<li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>:</b>performs subtraction (<code>-</code>)</li> |
| 2863 | | −<li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>:</b>performs multiplication (<code>*</code>)</li> |
| 2864 | | −<li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>:</b>performs division (<code>/</code>)</li> |
| 2865 | | −<li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>:</b>performs modulo (<code>%</code>)</li> |
| 2866 | | −<li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>:</b>performs exponentiation (<code>^</code>)</li> |
| 2867 | | −<li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>:</b>performs mathematical negation (unary <code>-</code>)</li> |
| 2872 | +<li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>: </b> performs addition (<code>+</code>)</li> |
| 2873 | +<li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>: </b> performs subtraction (<code>-</code>)</li> |
| 2874 | +<li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>: </b> performs multiplication (<code>*</code>)</li> |
| 2875 | +<li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>: </b> performs division (<code>/</code>)</li> |
| 2876 | +<li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>: </b> performs modulo (<code>%</code>)</li> |
| 2877 | +<li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>: </b> performs exponentiation (<code>^</code>)</li> |
| 2878 | +<li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>: </b> performs mathematical negation (unary <code>-</code>)</li> |
| 2868 | 2879 | |
| 2869 | 2880 | </ul> |
| 2870 | 2881 | |
| @@ -3068,9 +3079,9 @@ The value of <code>op</code> must be one of the following constants: · 197 unmodified lines |
| 3068 | 3079 | |
| 3069 | 3080 | <ul> |
| 3070 | 3081 | |
| 3071 | | −<li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>:</b>compares for equality (<code>==</code>)</li> |
| 3072 | | −<li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>:</b>compares for less than (<code><</code>)</li> |
| 3073 | | −<li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>:</b>compares for less or equal (<code><=</code>)</li> |
| 3082 | +<li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>: </b> compares for equality (<code>==</code>)</li> |
| 3083 | +<li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>: </b> compares for less than (<code><</code>)</li> |
| 3084 | +<li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code><=</code>)</li> |
| 3074 | 3085 | |
| 3075 | 3086 | </ul> |
| 3076 | 3087 | |
| @@ -3186,28 +3197,28 @@ according to the value of the parameter <code>what</code>: · 109 unmodified lines |
| 3186 | 3197 | |
| 3187 | 3198 | <ul> |
| 3188 | 3199 | |
| 3189 | | −<li><b><code>LUA_GCSTOP</code>:</b> |
| 3200 | +<li><b><code>LUA_GCSTOP</code>: </b> |
| 3190 | 3201 | stops the garbage collector. |
| 3191 | 3202 | </li> |
| 3192 | 3203 | |
| 3193 | | −<li><b><code>LUA_GCRESTART</code>:</b> |
| 3204 | +<li><b><code>LUA_GCRESTART</code>: </b> |
| 3194 | 3205 | restarts the garbage collector. |
| 3195 | 3206 | </li> |
| 3196 | 3207 | |
| 3197 | | −<li><b><code>LUA_GCCOLLECT</code>:</b> |
| 3208 | +<li><b><code>LUA_GCCOLLECT</code>: </b> |
| 3198 | 3209 | performs a full garbage-collection cycle. |
| 3199 | 3210 | </li> |
| 3200 | 3211 | |
| 3201 | | −<li><b><code>LUA_GCCOUNT</code>:</b> |
| 3212 | +<li><b><code>LUA_GCCOUNT</code>: </b> |
| 3202 | 3213 | returns the current amount of memory (in Kbytes) in use by Lua. |
| 3203 | 3214 | </li> |
| 3204 | 3215 | |
| 3205 | | −<li><b><code>LUA_GCCOUNTB</code>:</b> |
| 3216 | +<li><b><code>LUA_GCCOUNTB</code>: </b> |
| 3206 | 3217 | returns the remainder of dividing the current amount of bytes of |
| 3207 | 3218 | memory in use by Lua by 1024. |
| 3208 | 3219 | </li> |
| 3209 | 3220 | |
| 3210 | | −<li><b><code>LUA_GCSTEP</code>:</b> |
| 3221 | +<li><b><code>LUA_GCSTEP</code>: </b> |
| 3211 | 3222 | performs an incremental step of garbage collection. |
| 3212 | 3223 | The step "size" is controlled by <code>data</code> |
| 3213 | 3224 | (larger values mean more steps) in a non-specified way. |
| @@ -3217,19 +3228,19 @@ The function returns 1 if the step finished a · 3 unmodified lines |
| 3217 | 3228 | garbage-collection cycle. |
| 3218 | 3229 | </li> |
| 3219 | 3230 | |
| 3220 | | −<li><b><code>LUA_GCSETPAUSE</code>:</b> |
| 3231 | +<li><b><code>LUA_GCSETPAUSE</code>: </b> |
| 3221 | 3232 | sets <code>data</code> as the new value |
| 3222 | 3233 | for the <em>pause</em> of the collector (see <a href="#2.5">§2.5</a>). |
| 3223 | 3234 | The function returns the previous value of the pause. |
| 3224 | 3235 | </li> |
| 3225 | 3236 | |
| 3226 | | −<li><b><code>LUA_GCSETSTEPMUL</code>:</b> |
| 3237 | +<li><b><code>LUA_GCSETSTEPMUL</code>: </b> |
| 3227 | 3238 | sets <code>data</code> as the new value for the <em>step multiplier</em> of |
| 3228 | 3239 | the collector (see <a href="#2.5">§2.5</a>). |
| 3229 | 3240 | The function returns the previous value of the step multiplier. |
| 3230 | 3241 | </li> |
| 3231 | 3242 | |
| 3232 | | −<li><b><code>LUA_GCISRUNNING</code>:</b> |
| 3243 | +<li><b><code>LUA_GCISRUNNING</code>: </b> |
| 3233 | 3244 | returns a boolean that tells whether the collector is running |
| 3234 | 3245 | (i.e., not stopped). |
| 3235 | 3246 | </li> |
| @@ -3293,19 +3304,6 @@ as in the case of an yield. · 57 unmodified lines |
| 3293 | 3304 | |
| 3294 | 3305 | |
| 3295 | 3306 | |
| 3296 | | −<hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p> |
| 3297 | | −<span class="apii">[-0, +1, <em>-</em>]</span> |
| 3298 | | −<pre>void lua_getuservalue (lua_State *L, int index);</pre> |
| 3299 | | − |
| 3300 | | −<p> |
| 3301 | | −Pushes onto the stack the Lua value associated with the userdata |
| 3302 | | −at the given index. |
| 3303 | | −This Lua value must be a table or <b>nil</b>. |
| 3304 | | − |
| 3305 | | − |
| 3306 | | − |
| 3307 | | − |
| 3308 | | − |
| 3309 | 3307 | <hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p> |
| 3310 | 3308 | <span class="apii">[-0, +1, <em>e</em>]</span> |
| 3311 | 3309 | <pre>void lua_getfield (lua_State *L, int index, const char *k);</pre> |
| @@ -3381,6 +3379,19 @@ this result is equal to the number of elements in the stack · 69 unmodified lines |
| 3381 | 3379 | |
| 3382 | 3380 | |
| 3383 | 3381 | |
| 3382 | +<hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p> |
| 3383 | +<span class="apii">[-0, +1, <em>-</em>]</span> |
| 3384 | +<pre>void lua_getuservalue (lua_State *L, int index);</pre> |
| 3385 | + |
| 3386 | +<p> |
| 3387 | +Pushes onto the stack the Lua value associated with the userdata |
| 3388 | +at the given index. |
| 3389 | +This Lua value must be a table or <b>nil</b>. |
| 3390 | + |
| 3391 | + |
| 3392 | + |
| 3393 | + |
| 3394 | + |
| 3384 | 3395 | <hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p> |
| 3385 | 3396 | <span class="apii">[-1, +1, <em>-</em>]</span> |
| 3386 | 3397 | <pre>void lua_insert (lua_State *L, int index);</pre> |
| @@ -3590,15 +3601,15 @@ The return values of <a href="#lua_load"><code>lua_load</code></a> are: · 203 unmodified lines |
| 3590 | 3601 | |
| 3591 | 3602 | <ul> |
| 3592 | 3603 | |
| 3593 | | −<li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a> (0):</b> no errors;</li> |
| 3604 | +<li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b> no errors;</li> |
| 3594 | 3605 | |
| 3595 | | −<li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>:</b> |
| 3606 | +<li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>: </b> |
| 3596 | 3607 | syntax error during pre-compilation;</li> |
| 3597 | 3608 | |
| 3598 | | −<li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>:</b> |
| 3609 | +<li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b> |
| 3599 | 3610 | memory allocation error.</li> |
| 3600 | 3611 | |
| 3601 | | −<li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>:</b> |
| 3612 | +<li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b> |
| 3602 | 3613 | error while running a <code>__gc</code> metamethod. |
| 3603 | 3614 | (This error has no relation with the chunk being loaded. |
| 3604 | 3615 | It is generated by the garbage collector.) |
| @@ -3707,13 +3718,6 @@ and you can detect when it is being collected. · 102 unmodified lines |
| 3707 | 3718 | A full userdata is only equal to itself (under raw equality). |
| 3708 | 3719 | |
| 3709 | 3720 | |
| 3710 | | −<p> |
| 3711 | | −When Lua collects a full userdata with a <code>gc</code> metamethod, |
| 3712 | | −Lua calls the metamethod and marks the userdata as finalized. |
| 3713 | | −When this userdata is collected again then |
| 3714 | | −Lua frees its corresponding memory. |
| 3715 | | − |
| 3716 | | − |
| 3717 | 3721 | |
| 3718 | 3722 | |
| 3719 | 3723 | |
| @@ -3823,23 +3827,23 @@ The <a href="#lua_pcall"><code>lua_pcall</code></a> function returns one of the · 103 unmodified lines |
| 3823 | 3827 | |
| 3824 | 3828 | <ul> |
| 3825 | 3829 | |
| 3826 | | −<li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0):</b> |
| 3830 | +<li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b> |
| 3827 | 3831 | success.</li> |
| 3828 | 3832 | |
| 3829 | | −<li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>:</b> |
| 3833 | +<li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>: </b> |
| 3830 | 3834 | a runtime error. |
| 3831 | 3835 | </li> |
| 3832 | 3836 | |
| 3833 | | −<li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>:</b> |
| 3837 | +<li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b> |
| 3834 | 3838 | memory allocation error. |
| 3835 | 3839 | For such errors, Lua does not call the message handler. |
| 3836 | 3840 | </li> |
| 3837 | 3841 | |
| 3838 | | −<li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>:</b> |
| 3842 | +<li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>: </b> |
| 3839 | 3843 | error while running the message handler. |
| 3840 | 3844 | </li> |
| 3841 | 3845 | |
| 3842 | | −<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>:</b> |
| 3846 | +<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b> |
| 3843 | 3847 | error while running a <code>__gc</code> metamethod. |
| 3844 | 3848 | (This error typically has no relation with the function being called. |
| 3845 | 3849 | It is generated by the garbage collector.) |
| @@ -4018,7 +4022,7 @@ light userdata with the same C address. · 172 unmodified lines |
| 4018 | 4022 | |
| 4019 | 4023 | <hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p> |
| 4020 | 4024 | <span class="apii">[-0, +1, <em>m</em>]</span> |
| 4021 | | −<pre>void lua_pushliteral (lua_State *L, const char *s);</pre> |
| 4025 | +<pre>const char *lua_pushliteral (lua_State *L, const char *s);</pre> |
| 4022 | 4026 | |
| 4023 | 4027 | <p> |
| 4024 | 4028 | This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>, |
| @@ -4341,18 +4345,6 @@ with user data <code>ud</code>. · 316 unmodified lines |
| 4341 | 4345 | |
| 4342 | 4346 | |
| 4343 | 4347 | |
| 4344 | | −<hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p> |
| 4345 | | −<span class="apii">[-1, +0, <em>-</em>]</span> |
| 4346 | | −<pre>void lua_setuservalue (lua_State *L, int index);</pre> |
| 4347 | | − |
| 4348 | | −<p> |
| 4349 | | −Pops a table or <b>nil</b> from the stack and sets it as |
| 4350 | | −the new value associated to the userdata at the given index. |
| 4351 | | − |
| 4352 | | − |
| 4353 | | − |
| 4354 | | − |
| 4355 | | − |
| 4356 | 4348 | <hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p> |
| 4357 | 4349 | <span class="apii">[-1, +0, <em>e</em>]</span> |
| 4358 | 4350 | <pre>void lua_setfield (lua_State *L, int index, const char *k);</pre> |
| @@ -4433,6 +4425,18 @@ If <code>index</code> is 0, then all stack elements are removed. · 74 unmodified lines |
| 4433 | 4425 | |
| 4434 | 4426 | |
| 4435 | 4427 | |
| 4428 | +<hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p> |
| 4429 | +<span class="apii">[-1, +0, <em>-</em>]</span> |
| 4430 | +<pre>void lua_setuservalue (lua_State *L, int index);</pre> |
| 4431 | + |
| 4432 | +<p> |
| 4433 | +Pops a table or <b>nil</b> from the stack and sets it as |
| 4434 | +the new value associated to the userdata at the given index. |
| 4435 | + |
| 4436 | + |
| 4437 | + |
| 4438 | + |
| 4439 | + |
| 4436 | 4440 | <hr><h3><a name="lua_State"><code>lua_State</code></a></h3> |
| 4437 | 4441 | <pre>typedef struct lua_State lua_State;</pre> |
| 4438 | 4442 | |
| @@ -4919,7 +4923,7 @@ The fields of <a href="#lua_Debug"><code>lua_Debug</code></a> have the following · 480 unmodified lines |
| 4919 | 4923 | |
| 4920 | 4924 | <ul> |
| 4921 | 4925 | |
| 4922 | | −<li><b><code>source</code>:</b> |
| 4926 | +<li><b><code>source</code>: </b> |
| 4923 | 4927 | the source of the chunk that created the function. |
| 4924 | 4928 | If <code>source</code> starts with a '<code>@</code>', |
| 4925 | 4929 | it means that the function was defined in a file where |
| @@ -4931,31 +4935,31 @@ the function was defined in a string where · 5 unmodified lines |
| 4931 | 4935 | <code>source</code> is that string. |
| 4932 | 4936 | </li> |
| 4933 | 4937 | |
| 4934 | | −<li><b><code>short_src</code>:</b> |
| 4938 | +<li><b><code>short_src</code>: </b> |
| 4935 | 4939 | a "printable" version of <code>source</code>, to be used in error messages. |
| 4936 | 4940 | </li> |
| 4937 | 4941 | |
| 4938 | | −<li><b><code>linedefined</code>:</b> |
| 4942 | +<li><b><code>linedefined</code>: </b> |
| 4939 | 4943 | the line number where the definition of the function starts. |
| 4940 | 4944 | </li> |
| 4941 | 4945 | |
| 4942 | | −<li><b><code>lastlinedefined</code>:</b> |
| 4946 | +<li><b><code>lastlinedefined</code>: </b> |
| 4943 | 4947 | the line number where the definition of the function ends. |
| 4944 | 4948 | </li> |
| 4945 | 4949 | |
| 4946 | | −<li><b><code>what</code>:</b> |
| 4950 | +<li><b><code>what</code>: </b> |
| 4947 | 4951 | the string <code>"Lua"</code> if the function is a Lua function, |
| 4948 | 4952 | <code>"C"</code> if it is a C function, |
| 4949 | 4953 | <code>"main"</code> if it is the main part of a chunk. |
| 4950 | 4954 | </li> |
| 4951 | 4955 | |
| 4952 | | −<li><b><code>currentline</code>:</b> |
| 4956 | +<li><b><code>currentline</code>: </b> |
| 4953 | 4957 | the current line where the given function is executing. |
| 4954 | 4958 | When no line information is available, |
| 4955 | 4959 | <code>currentline</code> is set to -1. |
| 4956 | 4960 | </li> |
| 4957 | 4961 | |
| 4958 | | −<li><b><code>name</code>:</b> |
| 4962 | +<li><b><code>name</code>: </b> |
| 4959 | 4963 | a reasonable name for the given function. |
| 4960 | 4964 | Because functions in Lua are first-class values, |
| 4961 | 4965 | they do not have a fixed name: |
| @@ -4967,7 +4971,7 @@ If it cannot find a name, · 5 unmodified lines |
| 4967 | 4971 | then <code>name</code> is set to <code>NULL</code>. |
| 4968 | 4972 | </li> |
| 4969 | 4973 | |
| 4970 | | −<li><b><code>namewhat</code>:</b> |
| 4974 | +<li><b><code>namewhat</code>: </b> |
| 4971 | 4975 | explains the <code>name</code> field. |
| 4972 | 4976 | The value of <code>namewhat</code> can be |
| 4973 | 4977 | <code>"global"</code>, <code>"local"</code>, <code>"method"</code>, |
| @@ -4976,21 +4980,21 @@ according to how the function was called. · 2 unmodified lines |
| 4976 | 4980 | (Lua uses the empty string when no other option seems to apply.) |
| 4977 | 4981 | </li> |
| 4978 | 4982 | |
| 4979 | | −<li><b><code>istailcall</code>:</b> |
| 4983 | +<li><b><code>istailcall</code>: </b> |
| 4980 | 4984 | true if this function invocation was called by a tail call. |
| 4981 | 4985 | In this case, the caller of this level is not in the stack. |
| 4982 | 4986 | </li> |
| 4983 | 4987 | |
| 4984 | | −<li><b><code>nups</code>:</b> |
| 4988 | +<li><b><code>nups</code>: </b> |
| 4985 | 4989 | the number of upvalues of the function. |
| 4986 | 4990 | </li> |
| 4987 | 4991 | |
| 4988 | | −<li><b><code>nparams</code>:</b> |
| 4992 | +<li><b><code>nparams</code>: </b> |
| 4989 | 4993 | the number of fixed parameters of the function |
| 4990 | 4994 | (always 0 for C functions). |
| 4991 | 4995 | </li> |
| 4992 | 4996 | |
| 4993 | | −<li><b><code>isvararg</code>:</b> |
| 4997 | +<li><b><code>isvararg</code>: </b> |
| 4994 | 4998 | whether the function is a vararg function |
| 4995 | 4999 | (always true for C functions). |
| 4996 | 5000 | </li> |
| @@ -5070,29 +5074,30 @@ a value to be pushed on the stack: · 73 unmodified lines |
| 5070 | 5074 | |
| 5071 | 5075 | <ul> |
| 5072 | 5076 | |
| 5073 | | −<li><b>'<code>n</code>':</b> fills in the field <code>name</code> and <code>namewhat</code>; |
| 5077 | +<li><b>'<code>n</code>': </b> fills in the field <code>name</code> and <code>namewhat</code>; |
| 5074 | 5078 | </li> |
| 5075 | 5079 | |
| 5076 | | −<li><b>'<code>S</code>':</b> |
| 5080 | +<li><b>'<code>S</code>': </b> |
| 5077 | 5081 | fills in the fields <code>source</code>, <code>short_src</code>, |
| 5078 | 5082 | <code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>; |
| 5079 | 5083 | </li> |
| 5080 | 5084 | |
| 5081 | | −<li><b>'<code>l</code>':</b> fills in the field <code>currentline</code>; |
| 5085 | +<li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>; |
| 5082 | 5086 | </li> |
| 5083 | 5087 | |
| 5084 | | −<li><b>'<code>t</code>':</b> fills in the field <code>istailcall</code>; |
| 5088 | +<li><b>'<code>t</code>': </b> fills in the field <code>istailcall</code>; |
| 5085 | 5089 | </li> |
| 5086 | 5090 | |
| 5087 | | −<li><b>'<code>u</code>':</b> fills in the field <code>nups</code>; |
| 5091 | +<li><b>'<code>u</code>': </b> fills in the fields |
| 5092 | +<code>nups</code>, <code>nparams</code>, and <code>isvararg</code>; |
| 5088 | 5093 | </li> |
| 5089 | 5094 | |
| 5090 | | −<li><b>'<code>f</code>':</b> |
| 5095 | +<li><b>'<code>f</code>': </b> |
| 5091 | 5096 | pushes onto the stack the function that is |
| 5092 | 5097 | running at the given level; |
| 5093 | 5098 | </li> |
| 5094 | 5099 | |
| 5095 | | −<li><b>'<code>L</code>':</b> |
| 5100 | +<li><b>'<code>L</code>': </b> |
| 5096 | 5101 | pushes onto the stack a table whose indices are the |
| 5097 | 5102 | numbers of the lines that are valid on the function. |
| 5098 | 5103 | (A <em>valid line</em> is a line with some associated code, |
| @@ -5164,7 +5169,8 @@ This function fills parts of a <a href="#lua_Debug"><code>lua_Debug</code></a> s · 65 unmodified lines |
| 5164 | 5169 | an identification of the <em>activation record</em> |
| 5165 | 5170 | of the function executing at a given level. |
| 5166 | 5171 | Level 0 is the current running function, |
| 5167 | | −whereas level <em>n+1</em> is the function that has called level <em>n</em>. |
| 5172 | +whereas level <em>n+1</em> is the function that has called level <em>n</em> |
| 5173 | +(except for tail calls, which do not count on the stack). |
| 5168 | 5174 | When there are no errors, <a href="#lua_getstack"><code>lua_getstack</code></a> returns 1; |
| 5169 | 5175 | when called with a level greater than the stack depth, |
| 5170 | 5176 | it returns 0. |
| @@ -5257,24 +5263,24 @@ For each event, the hook is called as explained below: · 86 unmodified lines |
| 5257 | 5263 | |
| 5258 | 5264 | <ul> |
| 5259 | 5265 | |
| 5260 | | −<li><b>The call hook:</b> is called when the interpreter calls a function. |
| 5266 | +<li><b>The call hook: </b> is called when the interpreter calls a function. |
| 5261 | 5267 | The hook is called just after Lua enters the new function, |
| 5262 | 5268 | before the function gets its arguments. |
| 5263 | 5269 | </li> |
| 5264 | 5270 | |
| 5265 | | −<li><b>The return hook:</b> is called when the interpreter returns from a function. |
| 5271 | +<li><b>The return hook: </b> is called when the interpreter returns from a function. |
| 5266 | 5272 | The hook is called just before Lua leaves the function. |
| 5267 | 5273 | There is no standard way to access the values |
| 5268 | 5274 | to be returned by the function. |
| 5269 | 5275 | </li> |
| 5270 | 5276 | |
| 5271 | | −<li><b>The line hook:</b> is called when the interpreter is about to |
| 5277 | +<li><b>The line hook: </b> is called when the interpreter is about to |
| 5272 | 5278 | start the execution of a new line of code, |
| 5273 | 5279 | or when it jumps back in the code (even to the same line). |
| 5274 | 5280 | (This event only happens while Lua is executing a Lua function.) |
| 5275 | 5281 | </li> |
| 5276 | 5282 | |
| 5277 | | −<li><b>The count hook:</b> is called after the interpreter executes every |
| 5283 | +<li><b>The count hook: </b> is called after the interpreter executes every |
| 5278 | 5284 | <code>count</code> instructions. |
| 5279 | 5285 | (This event only happens while Lua is executing a Lua function.) |
| 5280 | 5286 | </li> |
| @@ -5333,7 +5339,7 @@ when the index is greater than the number of upvalues. · 52 unmodified lines |
| 5333 | 5339 | |
| 5334 | 5340 | <hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p> |
| 5335 | 5341 | <span class="apii">[-0, +0, <em>-</em>]</span> |
| 5336 | | −<pre>void *(lua_upvalueid) (lua_State *L, int funcindex, int n);</pre> |
| 5342 | +<pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre> |
| 5337 | 5343 | |
| 5338 | 5344 | <p> |
| 5339 | 5345 | Returns an unique identifier for the upvalue numbered <code>n</code> |
| @@ -5832,7 +5838,7 @@ and returns this number cast to a <a href="#lua_Unsigned"><code>lua_Unsigned</co · 492 unmodified lines |
| 5832 | 5838 | |
| 5833 | 5839 | <hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p> |
| 5834 | 5840 | <span class="apii">[-0, +0, <em>-</em>]</span> |
| 5835 | | −<pre>void *luaL_checkversion (lua_State *L);</pre> |
| 5841 | +<pre>void luaL_checkversion (lua_State *L);</pre> |
| 5836 | 5842 | |
| 5837 | 5843 | <p> |
| 5838 | 5844 | Checks whether the core running the call, |
| @@ -5919,9 +5925,9 @@ process-related functions in the standard library · 80 unmodified lines |
| 5919 | 5925 | |
| 5920 | 5926 | |
| 5921 | 5927 | <hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p> |
| 5922 | | −<span class="apii">[-0, +(1/3), <em>m</em>]</span> |
| 5928 | +<span class="apii">[-0, +(1|3), <em>m</em>]</span> |
| 5923 | 5929 | <pre>int luaL_fileresult (lua_State *L, int stat, |
| 5924 | | − const char *fname)</pre> |
| 5930 | + const char *fname);</pre> |
| 5925 | 5931 | |
| 5926 | 5932 | <p> |
| 5927 | 5933 | This function produces the return values for |
| @@ -6650,22 +6656,22 @@ It performs different functions according to its first argument, <code>opt</code · 722 unmodified lines |
| 6650 | 6656 | |
| 6651 | 6657 | <ul> |
| 6652 | 6658 | |
| 6653 | | −<li><b>"collect":</b> |
| 6659 | +<li><b>"collect": </b> |
| 6654 | 6660 | performs a full garbage-collection cycle. |
| 6655 | 6661 | This is the default option. |
| 6656 | 6662 | </li> |
| 6657 | 6663 | |
| 6658 | | −<li><b>"stop":</b> |
| 6664 | +<li><b>"stop": </b> |
| 6659 | 6665 | stops automatic invocation of the garbage collector. |
| 6660 | 6666 | The collector will run only when explcitly invoked, |
| 6661 | 6667 | until a call to restart it. |
| 6662 | 6668 | </li> |
| 6663 | 6669 | |
| 6664 | | −<li><b>"restart":</b> |
| 6670 | +<li><b>"restart": </b> |
| 6665 | 6671 | restarts automatic invocation the garbage collector. |
| 6666 | 6672 | </li> |
| 6667 | 6673 | |
| 6668 | | −<li><b>"count":</b> |
| 6674 | +<li><b>"count": </b> |
| 6669 | 6675 | returns the total memory in use by Lua (in Kbytes) and |
| 6670 | 6676 | a second value with the total memory in bytes modulo 1024. |
| 6671 | 6677 | The first value has a fractional part, |
| @@ -6679,7 +6685,7 @@ so the following equality is always true: · 7 unmodified lines |
| 6679 | 6685 | with a non floating-point type for numbers.) |
| 6680 | 6686 | </li> |
| 6681 | 6687 | |
| 6682 | | −<li><b>"step":</b> |
| 6688 | +<li><b>"step": </b> |
| 6683 | 6689 | performs a garbage-collection step. |
| 6684 | 6690 | The step "size" is controlled by <code>arg</code> |
| 6685 | 6691 | (larger values mean more steps) in a non-specified way. |
| @@ -6688,19 +6694,19 @@ you must experimentally tune the value of <code>arg</code>. · 2 unmodified lines |
| 6688 | 6694 | Returns <b>true</b> if the step finished a collection cycle. |
| 6689 | 6695 | </li> |
| 6690 | 6696 | |
| 6691 | | −<li><b>"setpause":</b> |
| 6697 | +<li><b>"setpause": </b> |
| 6692 | 6698 | sets <code>arg</code> as the new value for the <em>pause</em> of |
| 6693 | 6699 | the collector (see <a href="#2.5">§2.5</a>). |
| 6694 | 6700 | Returns the previous value for <em>pause</em>. |
| 6695 | 6701 | </li> |
| 6696 | 6702 | |
| 6697 | | −<li><b>"setstepmul":</b> |
| 6703 | +<li><b>"setstepmul": </b> |
| 6698 | 6704 | sets <code>arg</code> as the new value for the <em>step multiplier</em> of |
| 6699 | 6705 | the collector (see <a href="#2.5">§2.5</a>). |
| 6700 | 6706 | Returns the previous value for <em>step</em>. |
| 6701 | 6707 | </li> |
| 6702 | 6708 | |
| 6703 | | −<li><b>"isrunning":</b> |
| 6709 | +<li><b>"isrunning": </b> |
| 6704 | 6710 | returns a boolean that tells whether the collector is running |
| 6705 | 6711 | (i.e., not stopped). |
| 6706 | 6712 | </li> |
| @@ -7757,9 +7763,9 @@ The name <code>gsub</code> comes from <em>Global SUBstitution</em>. · 1050 unmodified lines |
| 7757 | 7763 | <p> |
| 7758 | 7764 | If <code>repl</code> is a string, then its value is used for replacement. |
| 7759 | 7765 | The character <code>%</code> works as an escape character: |
| 7760 | | −any sequence in <code>repl</code> of the form <code>%<em>n</em></code>, |
| 7761 | | −with <em>n</em> between 1 and 9, |
| 7762 | | −stands for the value of the <em>n</em>-th captured substring (see below). |
| 7766 | +any sequence in <code>repl</code> of the form <code>%<em>d</em></code>, |
| 7767 | +with <em>d</em> between 1 and 9, |
| 7768 | +stands for the value of the <em>d</em>-th captured substring (see below). |
| 7763 | 7769 | The sequence <code>%0</code> stands for the whole match. |
| 7764 | 7770 | The sequence <code>%%</code> stands for a single <code>%</code>. |
| 7765 | 7771 | |
| @@ -7903,35 +7909,35 @@ The following combinations are allowed in describing a character class: · 137 unmodified lines |
| 7903 | 7909 | |
| 7904 | 7910 | <ul> |
| 7905 | 7911 | |
| 7906 | | −<li><b><em>x</em>:</b> |
| 7912 | +<li><b><em>x</em>: </b> |
| 7907 | 7913 | (where <em>x</em> is not one of the <em>magic characters</em> |
| 7908 | 7914 | <code>^$()%.[]*+-?</code>) |
| 7909 | 7915 | represents the character <em>x</em> itself. |
| 7910 | 7916 | </li> |
| 7911 | 7917 | |
| 7912 | | −<li><b><code>.</code>:</b> (a dot) represents all characters.</li> |
| 7918 | +<li><b><code>.</code>: </b> (a dot) represents all characters.</li> |
| 7913 | 7919 | |
| 7914 | | −<li><b><code>%a</code>:</b> represents all letters.</li> |
| 7920 | +<li><b><code>%a</code>: </b> represents all letters.</li> |
| 7915 | 7921 | |
| 7916 | | −<li><b><code>%c</code>:</b> represents all control characters.</li> |
| 7922 | +<li><b><code>%c</code>: </b> represents all control characters.</li> |
| 7917 | 7923 | |
| 7918 | | −<li><b><code>%d</code>:</b> represents all digits.</li> |
| 7924 | +<li><b><code>%d</code>: </b> represents all digits.</li> |
| 7919 | 7925 | |
| 7920 | | −<li><b><code>%g</code>:</b> represents all printable characters except space.</li> |
| 7926 | +<li><b><code>%g</code>: </b> represents all printable characters except space.</li> |
| 7921 | 7927 | |
| 7922 | | −<li><b><code>%l</code>:</b> represents all lowercase letters.</li> |
| 7928 | +<li><b><code>%l</code>: </b> represents all lowercase letters.</li> |
| 7923 | 7929 | |
| 7924 | | −<li><b><code>%p</code>:</b> represents all punctuation characters.</li> |
| 7930 | +<li><b><code>%p</code>: </b> represents all punctuation characters.</li> |
| 7925 | 7931 | |
| 7926 | | −<li><b><code>%s</code>:</b> represents all space characters.</li> |
| 7932 | +<li><b><code>%s</code>: </b> represents all space characters.</li> |
| 7927 | 7933 | |
| 7928 | | −<li><b><code>%u</code>:</b> represents all uppercase letters.</li> |
| 7934 | +<li><b><code>%u</code>: </b> represents all uppercase letters.</li> |
| 7929 | 7935 | |
| 7930 | | −<li><b><code>%w</code>:</b> represents all alphanumeric characters.</li> |
| 7936 | +<li><b><code>%w</code>: </b> represents all alphanumeric characters.</li> |
| 7931 | 7937 | |
| 7932 | | −<li><b><code>%x</code>:</b> represents all hexadecimal digits.</li> |
| 7938 | +<li><b><code>%x</code>: </b> represents all hexadecimal digits.</li> |
| 7933 | 7939 | |
| 7934 | | −<li><b><code>%<em>x</em></code>:</b> (where <em>x</em> is any non-alphanumeric character) |
| 7940 | +<li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character) |
| 7935 | 7941 | represents the character <em>x</em>. |
| 7936 | 7942 | This is the standard way to escape the magic characters. |
| 7937 | 7943 | Any punctuation character (even the non magic) |
| @@ -7939,7 +7945,7 @@ can be preceded by a '<code>%</code>' · 1 unmodified line |
| 7939 | 7945 | when used to represent itself in a pattern. |
| 7940 | 7946 | </li> |
| 7941 | 7947 | |
| 7942 | | −<li><b><code>[<em>set</em>]</code>:</b> |
| 7948 | +<li><b><code>[<em>set</em>]</code>: </b> |
| 7943 | 7949 | represents the class which is the union of all |
| 7944 | 7950 | characters in <em>set</em>. |
| 7945 | 7951 | A range of characters can be specified by |
| @@ -7961,7 +7967,7 @@ Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code> · 15 unmodified lines |
| 7961 | 7967 | have no meaning. |
| 7962 | 7968 | </li> |
| 7963 | 7969 | |
| 7964 | | −<li><b><code>[^<em>set</em>]</code>:</b> |
| 7970 | +<li><b><code>[^<em>set</em>]</code>: </b> |
| 7965 | 7971 | represents the complement of <em>set</em>, |
| 7966 | 7972 | where <em>set</em> is interpreted as above. |
| 7967 | 7973 | </li> |
| @@ -8097,13 +8103,11 @@ It provides all its functions inside the table <a name="pdf-table"><code>table</ · 129 unmodified lines |
| 8097 | 8103 | |
| 8098 | 8104 | |
| 8099 | 8105 | <p> |
| 8100 | | −Currently, all functions in the table library, |
| 8101 | | −except <a href="#pdf-table.pack"><code>table.pack</code></a>, |
| 8102 | | −work on lists. |
| 8103 | | −A list here means a proper sequence |
| 8104 | | −or a table with a <code>__len</code> metamethod (see <a href="#3.4.6">§3.4.6</a>). |
| 8105 | | −In particular, all functions ignore non-numeric keys |
| 8106 | | −in lists given as arguments. |
| 8106 | +Remember that, whenever an operation needs the length of a table, |
| 8107 | +the table should be a proper sequence |
| 8108 | +or have a <code>__len</code> metamethod (see <a href="#3.4.6">§3.4.6</a>). |
| 8109 | +All functions ignore non-numeric keys |
| 8110 | +in tables given as arguments. |
| 8107 | 8111 | |
| 8108 | 8112 | |
| 8109 | 8113 | <p> |
| @@ -8642,7 +8646,7 @@ Returns the bitwise exclusive or of its operands. · 532 unmodified lines |
| 8642 | 8646 | |
| 8643 | 8647 | |
| 8644 | 8648 | <p> |
| 8645 | | −<hr><h3><a name="pdf-bit32.extract"><code>bit32.extract (n, field, width)</code></a></h3> |
| 8649 | +<hr><h3><a name="pdf-bit32.extract"><code>bit32.extract (n, field [, width])</code></a></h3> |
| 8646 | 8650 | |
| 8647 | 8651 | |
| 8648 | 8652 | <p> |
| @@ -8652,10 +8656,14 @@ Bits are numbered from 0 (least significant) to 31 (most significant). · 3 unmodified lines |
| 8652 | 8656 | All accessed bits must be in the range <em>[0, 31]</em>. |
| 8653 | 8657 | |
| 8654 | 8658 | |
| 8659 | +<p> |
| 8660 | +The default for <code>width</code> is 1. |
| 8661 | + |
| 8662 | + |
| 8655 | 8663 | |
| 8656 | 8664 | |
| 8657 | 8665 | <p> |
| 8658 | | −<hr><h3><a name="pdf-bit32.replace"><code>bit32.replace (n, v, field, width)</code></a></h3> |
| 8666 | +<hr><h3><a name="pdf-bit32.replace"><code>bit32.replace (n, v, field [, width])</code></a></h3> |
| 8659 | 8667 | |
| 8660 | 8668 | |
| 8661 | 8669 | <p> |
| @@ -8848,7 +8856,7 @@ instead of returning an error code. · 186 unmodified lines |
| 8848 | 8856 | <p> |
| 8849 | 8857 | Opens the given file name in read mode |
| 8850 | 8858 | and returns an iterator function that |
| 8851 | | −works like <code>file:lines(···)</code> over the oppened file. |
| 8859 | +works like <code>file:lines(···)</code> over the opened file. |
| 8852 | 8860 | When the iterator function detects the end of file, |
| 8853 | 8861 | it returns <b>nil</b> (to finish the loop) and automatically closes the file. |
| 8854 | 8862 | |
| @@ -8877,12 +8885,12 @@ or, in case of errors, <b>nil</b> plus an error message. · 22 unmodified lines |
| 8877 | 8885 | The <code>mode</code> string can be any of the following: |
| 8878 | 8886 | |
| 8879 | 8887 | <ul> |
| 8880 | | −<li><b>"r":</b> read mode (the default);</li> |
| 8881 | | −<li><b>"w":</b> write mode;</li> |
| 8882 | | −<li><b>"a":</b> append mode;</li> |
| 8883 | | −<li><b>"r+":</b> update mode, all previous data is preserved;</li> |
| 8884 | | −<li><b>"w+":</b> update mode, all previous data is erased;</li> |
| 8885 | | −<li><b>"a+":</b> append update mode, previous data is preserved, |
| 8888 | +<li><b>"r": </b> read mode (the default);</li> |
| 8889 | +<li><b>"w": </b> write mode;</li> |
| 8890 | +<li><b>"a": </b> append mode;</li> |
| 8891 | +<li><b>"r+": </b> update mode, all previous data is preserved;</li> |
| 8892 | +<li><b>"w+": </b> update mode, all previous data is erased;</li> |
| 8893 | +<li><b>"a+": </b> append update mode, previous data is preserved, |
| 8886 | 8894 | writing is only allowed at the end of file.</li> |
| 8887 | 8895 | </ul><p> |
| 8888 | 8896 | The <code>mode</code> string can also have a '<code>b</code>' at the end, |
| @@ -9037,28 +9045,28 @@ The available formats are · 148 unmodified lines |
| 9037 | 9045 | |
| 9038 | 9046 | <ul> |
| 9039 | 9047 | |
| 9040 | | −<li><b>"*n":</b> |
| 9048 | +<li><b>"*n": </b> |
| 9041 | 9049 | reads a number; |
| 9042 | 9050 | this is the only format that returns a number instead of a string. |
| 9043 | 9051 | </li> |
| 9044 | 9052 | |
| 9045 | | −<li><b>"*a":</b> |
| 9053 | +<li><b>"*a": </b> |
| 9046 | 9054 | reads the whole file, starting at the current position. |
| 9047 | 9055 | On end of file, it returns the empty string. |
| 9048 | 9056 | </li> |
| 9049 | 9057 | |
| 9050 | | −<li><b>"*l":</b> |
| 9058 | +<li><b>"*l": </b> |
| 9051 | 9059 | reads the next line skipping the end of line, |
| 9052 | 9060 | returning <b>nil</b> on end of file. |
| 9053 | 9061 | This is the default format. |
| 9054 | 9062 | </li> |
| 9055 | 9063 | |
| 9056 | | −<li><b>"*L":</b> |
| 9064 | +<li><b>"*L": </b> |
| 9057 | 9065 | reads the next line keeping the end of line (if present), |
| 9058 | 9066 | returning <b>nil</b> on end of file. |
| 9059 | 9067 | </li> |
| 9060 | 9068 | |
| 9061 | | −<li><b><em>number</em>:</b> |
| 9069 | +<li><b><em>number</em>: </b> |
| 9062 | 9070 | reads a string with up to this number of characters, |
| 9063 | 9071 | returning <b>nil</b> on end of file. |
| 9064 | 9072 | If number is zero, |
| @@ -9081,9 +9089,9 @@ to the position given by <code>offset</code> plus a base · 16 unmodified lines |
| 9081 | 9089 | specified by the string <code>whence</code>, as follows: |
| 9082 | 9090 | |
| 9083 | 9091 | <ul> |
| 9084 | | −<li><b>"set":</b> base is position 0 (beginning of the file);</li> |
| 9085 | | −<li><b>"cur":</b> base is current position;</li> |
| 9086 | | −<li><b>"end":</b> base is end of file;</li> |
| 9092 | +<li><b>"set": </b> base is position 0 (beginning of the file);</li> |
| 9093 | +<li><b>"cur": </b> base is current position;</li> |
| 9094 | +<li><b>"end": </b> base is end of file;</li> |
| 9087 | 9095 | </ul><p> |
| 9088 | 9096 | In case of success, function <code>seek</code> returns the final file position, |
| 9089 | 9097 | measured in bytes from the beginning of the file. |
| @@ -9114,17 +9122,17 @@ There are three available modes: · 24 unmodified lines |
| 9114 | 9122 | |
| 9115 | 9123 | <ul> |
| 9116 | 9124 | |
| 9117 | | −<li><b>"no":</b> |
| 9125 | +<li><b>"no": </b> |
| 9118 | 9126 | no buffering; the result of any output operation appears immediately. |
| 9119 | 9127 | </li> |
| 9120 | 9128 | |
| 9121 | | −<li><b>"full":</b> |
| 9129 | +<li><b>"full": </b> |
| 9122 | 9130 | full buffering; output operation is performed only |
| 9123 | 9131 | when the buffer is full (or when you explicitly <code>flush</code> the file |
| 9124 | 9132 | (see <a href="#pdf-io.flush"><code>io.flush</code></a>)). |
| 9125 | 9133 | </li> |
| 9126 | 9134 | |
| 9127 | | −<li><b>"line":</b> |
| 9135 | +<li><b>"line": </b> |
| 9128 | 9136 | line buffering; output is buffered until a newline is output |
| 9129 | 9137 | or there is any input from some special files |
| 9130 | 9138 | (such as a terminal device). |
| @@ -9251,12 +9259,12 @@ as follows: · 120 unmodified lines |
| 9251 | 9259 | |
| 9252 | 9260 | <ul> |
| 9253 | 9261 | |
| 9254 | | −<li><b>"<code>exit</code>":</b> |
| 9262 | +<li><b>"<code>exit</code>": </b> |
| 9255 | 9263 | the command terminated normally; |
| 9256 | 9264 | the following number is the exit status of the command. |
| 9257 | 9265 | </li> |
| 9258 | 9266 | |
| 9259 | | −<li><b>"<code>signal</code>":</b> |
| 9267 | +<li><b>"<code>signal</code>": </b> |
| 9260 | 9268 | the command was terminated by a signal; |
| 9261 | 9269 | the following number is the signal that terminated the command. |
| 9262 | 9270 | </li> |
| @@ -9460,18 +9468,6 @@ within any function, and so have no direct access to local variables. · 197 unmodified lines |
| 9460 | 9468 | |
| 9461 | 9469 | |
| 9462 | 9470 | |
| 9463 | | −<p> |
| 9464 | | −<hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3> |
| 9465 | | − |
| 9466 | | − |
| 9467 | | −<p> |
| 9468 | | −Returns the Lua value associated to <code>u</code>. |
| 9469 | | −If <code>u</code> is not a userdata, |
| 9470 | | −returns <b>nil</b>. |
| 9471 | | − |
| 9472 | | − |
| 9473 | | − |
| 9474 | | − |
| 9475 | 9471 | <p> |
| 9476 | 9472 | <hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3> |
| 9477 | 9473 | |
| @@ -9596,18 +9592,13 @@ The function returns <b>nil</b> if there is no upvalue with the given index. · 118 unmodified lines |
| 9596 | 9592 | |
| 9597 | 9593 | |
| 9598 | 9594 | <p> |
| 9599 | | −<hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3> |
| 9600 | | − |
| 9601 | | − |
| 9602 | | −<p> |
| 9603 | | −Sets the given <code>value</code> as |
| 9604 | | −the Lua value associated to the given <code>udata</code>. |
| 9605 | | −<code>value</code> must be a table or <b>nil</b>; |
| 9606 | | −<code>udata</code> must be a full userdata. |
| 9595 | +<hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3> |
| 9607 | 9596 | |
| 9608 | 9597 | |
| 9609 | 9598 | <p> |
| 9610 | | −Returns <code>udata</code>. |
| 9599 | +Returns the Lua value associated to <code>u</code>. |
| 9600 | +If <code>u</code> is not a userdata, |
| 9601 | +returns <b>nil</b>. |
| 9611 | 9602 | |
| 9612 | 9603 | |
| 9613 | 9604 | |
| @@ -9624,9 +9615,9 @@ The string mask may have the following characters, · 10 unmodified lines |
| 9624 | 9615 | with the given meaning: |
| 9625 | 9616 | |
| 9626 | 9617 | <ul> |
| 9627 | | −<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li> |
| 9628 | | −<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li> |
| 9629 | | −<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li> |
| 9618 | +<li><b><code>"c"</code>: </b> the hook is called every time Lua calls a function;</li> |
| 9619 | +<li><b><code>"r"</code>: </b> the hook is called every time Lua returns from a function;</li> |
| 9620 | +<li><b><code>"l"</code>: </b> the hook is called every time Lua enters a new line of code.</li> |
| 9630 | 9621 | </ul><p> |
| 9631 | 9622 | With a <code>count</code> different from zero, |
| 9632 | 9623 | the hook is called after every <code>count</code> instructions. |
| @@ -9701,6 +9692,23 @@ Otherwise, it returns the name of the upvalue. · 68 unmodified lines |
| 9701 | 9692 | |
| 9702 | 9693 | |
| 9703 | 9694 | |
| 9695 | +<p> |
| 9696 | +<hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3> |
| 9697 | + |
| 9698 | + |
| 9699 | +<p> |
| 9700 | +Sets the given <code>value</code> as |
| 9701 | +the Lua value associated to the given <code>udata</code>. |
| 9702 | +<code>value</code> must be a table or <b>nil</b>; |
| 9703 | +<code>udata</code> must be a full userdata. |
| 9704 | + |
| 9705 | + |
| 9706 | +<p> |
| 9707 | +Returns <code>udata</code>. |
| 9708 | + |
| 9709 | + |
| 9710 | + |
| 9711 | + |
| 9704 | 9712 | <p> |
| 9705 | 9713 | <hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code></a></h3> |
| 9706 | 9714 | |
| @@ -9772,12 +9780,12 @@ Its usage is: · 65 unmodified lines |
| 9772 | 9780 | The options are: |
| 9773 | 9781 | |
| 9774 | 9782 | <ul> |
| 9775 | | −<li><b><code>-e <em>stat</em></code>:</b> executes string <em>stat</em>;</li> |
| 9776 | | −<li><b><code>-l <em>mod</em></code>:</b> "requires" <em>mod</em>;</li> |
| 9777 | | −<li><b><code>-i</code>:</b> enters interactive mode after running <em>script</em>;</li> |
| 9778 | | −<li><b><code>-v</code>:</b> prints version information;</li> |
| 9779 | | −<li><b><code>--</code>:</b> stops handling options;</li> |
| 9780 | | −<li><b><code>-</code>:</b> executes <code>stdin</code> as a file and stops handling options.</li> |
| 9783 | +<li><b><code>-e <em>stat</em></code>: </b> executes string <em>stat</em>;</li> |
| 9784 | +<li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em>;</li> |
| 9785 | +<li><b><code>-i</code>: </b> enters interactive mode after running <em>script</em>;</li> |
| 9786 | +<li><b><code>-v</code>: </b> prints version information;</li> |
| 9787 | +<li><b><code>--</code>: </b> stops handling options;</li> |
| 9788 | +<li><b><code>-</code>: </b> executes <code>stdin</code> as a file and stops handling options.</li> |
| 9781 | 9789 | </ul><p> |
| 9782 | 9790 | After handling its options, <code>lua</code> runs the given <em>script</em>, |
| 9783 | 9791 | passing to it the given <em>args</em> as string arguments. |
| @@ -10195,7 +10203,7 @@ Here is the complete syntax of Lua in extended BNF. · 411 unmodified lines |
| 10195 | 10203 | <HR> |
| 10196 | 10204 | <SMALL CLASS="footer"> |
| 10197 | 10205 | Last update: |
| 10198 | | −Tue Jun 21 19:09:27 BRT 2011 |
| 10206 | +Mon Jun 27 15:48:15 BRT 2011 |
| 10199 | 10207 | </SMALL> |
| 10200 | 10208 | <!-- |
| 10201 | 10209 | Last change: revised for Lua 5.2.0 (beta) |