diff options
Diffstat (limited to 'manual/manual.of')
-rw-r--r-- | manual/manual.of | 537 |
1 files changed, 287 insertions, 250 deletions
diff --git a/manual/manual.of b/manual/manual.of index cef3e22a..e3cbddb3 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -621,7 +621,8 @@ that is inaccessible from Lua. | |||
621 | another live object refer to the object.) | 621 | another live object refer to the object.) |
622 | Because Lua has no knowledge about @N{C code}, | 622 | Because Lua has no knowledge about @N{C code}, |
623 | it never collects objects accessible through the registry @see{registry}, | 623 | it never collects objects accessible through the registry @see{registry}, |
624 | which includes the global environment @see{globalenv}. | 624 | which includes the global environment @see{globalenv} and |
625 | the main thread. | ||
625 | 626 | ||
626 | 627 | ||
627 | The garbage collector (GC) in Lua can work in two modes: | 628 | The garbage collector (GC) in Lua can work in two modes: |
@@ -638,8 +639,8 @@ therefore, optimal settings are also non-portable. | |||
638 | You can change the GC mode and parameters by calling | 639 | You can change the GC mode and parameters by calling |
639 | @Lid{lua_gc} @N{in C} | 640 | @Lid{lua_gc} @N{in C} |
640 | or @Lid{collectgarbage} in Lua. | 641 | or @Lid{collectgarbage} in Lua. |
641 | You can also use these functions to control | 642 | You can also use these functions to control the collector directly, |
642 | the collector directly (e.g., to stop and restart it). | 643 | for instance to stop or restart it. |
643 | 644 | ||
644 | } | 645 | } |
645 | 646 | ||
@@ -656,39 +657,33 @@ and the @def{garbage-collector step size}. | |||
656 | 657 | ||
657 | The garbage-collector pause | 658 | The garbage-collector pause |
658 | controls how long the collector waits before starting a new cycle. | 659 | controls how long the collector waits before starting a new cycle. |
659 | The collector starts a new cycle when the use of memory | 660 | The collector starts a new cycle when the number of objects |
660 | hits @M{n%} of the use after the previous collection. | 661 | hits @M{n%} of the total after the previous collection. |
661 | Larger values make the collector less aggressive. | 662 | Larger values make the collector less aggressive. |
662 | Values equal to or less than 100 mean the collector will not wait to | 663 | Values equal to or less than 100 mean the collector will not wait to |
663 | start a new cycle. | 664 | start a new cycle. |
664 | A value of 200 means that the collector waits for the total memory in use | 665 | A value of 200 means that the collector waits for |
665 | to double before starting a new cycle. | 666 | the total number of objects to double before starting a new cycle. |
666 | The default value is 200; the maximum value is 1000. | 667 | The default value is 200. |
667 | |||
668 | The garbage-collector step multiplier | ||
669 | controls the speed of the collector relative to | ||
670 | memory allocation, | ||
671 | that is, | ||
672 | how many elements it marks or sweeps for each | ||
673 | kilobyte of memory allocated. | ||
674 | Larger values make the collector more aggressive but also increase | ||
675 | the size of each incremental step. | ||
676 | You should not use values less than 100, | ||
677 | because they make the collector too slow and | ||
678 | can result in the collector never finishing a cycle. | ||
679 | The default value is 100; the maximum value is 1000. | ||
680 | 668 | ||
681 | The garbage-collector step size controls the | 669 | The garbage-collector step size controls the |
682 | size of each incremental step, | 670 | size of each incremental step, |
683 | specifically how many bytes the interpreter allocates | 671 | specifically how many objects the interpreter creates |
684 | before performing a step. | 672 | before performing a step: |
685 | This parameter is logarithmic: | 673 | A value of @M{n} means the interpreter will create |
686 | A value of @M{n} means the interpreter will allocate @M{2@sp{n}} | 674 | approximately @M{n} objects between steps. |
687 | bytes between steps and perform equivalent work during the step. | 675 | The default value is 250. |
688 | A large value (e.g., 60) makes the collector a stop-the-world | 676 | |
689 | (non-incremental) collector. | 677 | The garbage-collector step multiplier |
690 | The default value is 13, | 678 | controls the size of each GC step. |
691 | which means steps of approximately @N{8 Kbytes}. | 679 | A value of @M{n} means the interpreter will mark or sweep, |
680 | in each step, @M{n%} objects for each created object. | ||
681 | Larger values make the collector more aggressive. | ||
682 | Beware that values too small can | ||
683 | make the collector too slow to ever finish a cycle. | ||
684 | The default value is 200. | ||
685 | As a special case, a zero value means unlimited work, | ||
686 | effectively producing a non-incremental, stop-the-world collector. | ||
692 | 687 | ||
693 | } | 688 | } |
694 | 689 | ||
@@ -697,31 +692,46 @@ which means steps of approximately @N{8 Kbytes}. | |||
697 | In generational mode, | 692 | In generational mode, |
698 | the collector does frequent @emph{minor} collections, | 693 | the collector does frequent @emph{minor} collections, |
699 | which traverses only objects recently created. | 694 | which traverses only objects recently created. |
700 | If after a minor collection the use of memory is still above a limit, | 695 | If after a minor collection the number of objects is above a limit, |
701 | the collector does a stop-the-world @emph{major} collection, | 696 | the collector shifts to a @emph{major} collection, |
702 | which traverses all objects. | 697 | which traverses all objects. |
703 | The generational mode uses two parameters: | 698 | The collector will then stay doing major collections until |
704 | the @def{minor multiplier} and the @def{the major multiplier}. | 699 | it detects that the program is generating enough garbage to justify |
700 | going back to minor collections. | ||
701 | |||
702 | The generational mode uses three parameters: | ||
703 | the @def{minor multiplier}, the @def{minor-major multiplier}, | ||
704 | and the @def{major-minor multiplier}. | ||
705 | 705 | ||
706 | The minor multiplier controls the frequency of minor collections. | 706 | The minor multiplier controls the frequency of minor collections. |
707 | For a minor multiplier @M{x}, | 707 | For a minor multiplier @M{x}, |
708 | a new minor collection will be done when memory | 708 | a new minor collection will be done when the number of objects |
709 | grows @M{x%} larger than the memory in use after the previous major | 709 | grows @M{x%} larger than the number in use just |
710 | collection. | 710 | after the last major collection. |
711 | For instance, for a multiplier of 20, | 711 | For instance, for a multiplier of 20, |
712 | the collector will do a minor collection when the use of memory | 712 | the collector will do a minor collection when the number of objects |
713 | gets 20% larger than the use after the previous major collection. | 713 | gets 20% larger than the total after the last major collection. |
714 | The default value is 20; the maximum value is 200. | 714 | The default value is 25. |
715 | 715 | ||
716 | The major multiplier controls the frequency of major collections. | 716 | The minor-major multiplier controls the shift to major collections. |
717 | For a major multiplier @M{x}, | 717 | For a multiplier @M{x}, |
718 | a new major collection will be done when memory | 718 | the collector will shift to a major collection |
719 | grows @M{x%} larger than the memory in use after the previous major | 719 | when the number of old objects grows @M{x%} larger |
720 | collection. | 720 | than the total after the previous major collection. |
721 | For instance, for a multiplier of 100, | 721 | For instance, for a multiplier of 100, |
722 | the collector will do a major collection when the use of memory | 722 | the collector will do a major collection when the number of old objects |
723 | gets larger than twice the use after the previous collection. | 723 | gets larger than twice the total after the previous major collection. |
724 | The default value is 100; the maximum value is 1000. | 724 | The default value is 100. |
725 | |||
726 | The major-minor multiplier controls the shift back to minor collections. | ||
727 | For a multiplier @M{x}, | ||
728 | the collector will shift back to minor collections | ||
729 | after a major collection collects at least @M{x%} | ||
730 | of the objects allocated during the last cycle. | ||
731 | In particular, for a multiplier of 0, | ||
732 | the collector will immediately shift back to minor collections | ||
733 | after doing one cycle of major collections. | ||
734 | The default value is 50. | ||
725 | 735 | ||
726 | } | 736 | } |
727 | 737 | ||
@@ -1467,7 +1477,7 @@ It has the following syntax: | |||
1467 | exp @bnfter{,} exp @bnfopt{@bnfter{,} exp} @Rw{do} block @Rw{end}} | 1477 | exp @bnfter{,} exp @bnfopt{@bnfter{,} exp} @Rw{do} block @Rw{end}} |
1468 | } | 1478 | } |
1469 | The given identifier (@bnfNter{Name}) defines the control variable, | 1479 | The given identifier (@bnfNter{Name}) defines the control variable, |
1470 | which is a new variable local to the loop body (@emph{block}). | 1480 | which is a new read-only variable local to the loop body (@emph{block}). |
1471 | 1481 | ||
1472 | The loop starts by evaluating once the three control expressions. | 1482 | The loop starts by evaluating once the three control expressions. |
1473 | Their values are called respectively | 1483 | Their values are called respectively |
@@ -1499,11 +1509,6 @@ For integer loops, | |||
1499 | the control variable never wraps around; | 1509 | the control variable never wraps around; |
1500 | instead, the loop ends in case of an overflow. | 1510 | instead, the loop ends in case of an overflow. |
1501 | 1511 | ||
1502 | You should not change the value of the control variable | ||
1503 | during the loop. | ||
1504 | If you need its value after the loop, | ||
1505 | assign it to another variable before exiting the loop. | ||
1506 | |||
1507 | } | 1512 | } |
1508 | 1513 | ||
1509 | @sect4{@title{The generic @Rw{for} loop} | 1514 | @sect4{@title{The generic @Rw{for} loop} |
@@ -1526,7 +1531,8 @@ for @rep{var_1}, @Cdots, @rep{var_n} in @rep{explist} do @rep{body} end | |||
1526 | works as follows. | 1531 | works as follows. |
1527 | 1532 | ||
1528 | The names @rep{var_i} declare loop variables local to the loop body. | 1533 | The names @rep{var_i} declare loop variables local to the loop body. |
1529 | The first of these variables is the @emph{control variable}. | 1534 | The first of these variables is the @emph{control variable}, |
1535 | which is a read-only variable. | ||
1530 | 1536 | ||
1531 | The loop starts by evaluating @rep{explist} | 1537 | The loop starts by evaluating @rep{explist} |
1532 | to produce four values: | 1538 | to produce four values: |
@@ -1550,9 +1556,6 @@ to-be-closed variable @see{to-be-closed}, | |||
1550 | which can be used to release resources when the loop ends. | 1556 | which can be used to release resources when the loop ends. |
1551 | Otherwise, it does not interfere with the loop. | 1557 | Otherwise, it does not interfere with the loop. |
1552 | 1558 | ||
1553 | You should not change the value of the control variable | ||
1554 | during the loop. | ||
1555 | |||
1556 | } | 1559 | } |
1557 | 1560 | ||
1558 | } | 1561 | } |
@@ -1586,7 +1589,8 @@ Each variable name may be postfixed by an attribute | |||
1586 | @producname{attrib}@producbody{@bnfopt{@bnfter{<} @bnfNter{Name} @bnfter{>}}} | 1589 | @producname{attrib}@producbody{@bnfopt{@bnfter{<} @bnfNter{Name} @bnfter{>}}} |
1587 | } | 1590 | } |
1588 | There are two possible attributes: | 1591 | There are two possible attributes: |
1589 | @id{const}, which declares a @x{constant variable}, | 1592 | @id{const}, which declares a @emph{constant} or @emph{read-only} variable, |
1593 | @index{constant variable} | ||
1590 | that is, a variable that cannot be assigned to | 1594 | that is, a variable that cannot be assigned to |
1591 | after its initialization; | 1595 | after its initialization; |
1592 | and @id{close}, which declares a to-be-closed variable @see{to-be-closed}. | 1596 | and @id{close}, which declares a to-be-closed variable @see{to-be-closed}. |
@@ -2569,8 +2573,8 @@ See also @Lid{luaL_checklstring}, @Lid{luaL_checkstring}, | |||
2569 | and @Lid{luaL_tolstring} in the auxiliary library.) | 2573 | and @Lid{luaL_tolstring} in the auxiliary library.) |
2570 | 2574 | ||
2571 | In general, | 2575 | In general, |
2572 | Lua's garbage collection can free or move internal memory | 2576 | Lua's garbage collection can free or move memory |
2573 | and then invalidate pointers to internal strings. | 2577 | and then invalidate pointers to strings handled by a Lua state. |
2574 | To allow a safe use of these pointers, | 2578 | To allow a safe use of these pointers, |
2575 | the API guarantees that any pointer to a string in a stack index | 2579 | the API guarantees that any pointer to a string in a stack index |
2576 | is valid while the string value at that index is not removed from the stack. | 2580 | is valid while the string value at that index is not removed from the stack. |
@@ -2641,8 +2645,8 @@ string keys starting with an underscore followed by | |||
2641 | uppercase letters are reserved for Lua. | 2645 | uppercase letters are reserved for Lua. |
2642 | 2646 | ||
2643 | The integer keys in the registry are used | 2647 | The integer keys in the registry are used |
2644 | by the reference mechanism @seeC{luaL_ref} | 2648 | by the reference mechanism @seeC{luaL_ref}, |
2645 | and by some predefined values. | 2649 | with some predefined values. |
2646 | Therefore, integer keys in the registry | 2650 | Therefore, integer keys in the registry |
2647 | must not be used for other purposes. | 2651 | must not be used for other purposes. |
2648 | 2652 | ||
@@ -2736,7 +2740,8 @@ For such errors, Lua does not call the @x{message handler}. | |||
2736 | 2740 | ||
2737 | @item{@defid{LUA_ERRERR}| error while running the @x{message handler}.} | 2741 | @item{@defid{LUA_ERRERR}| error while running the @x{message handler}.} |
2738 | 2742 | ||
2739 | @item{@defid{LUA_ERRSYNTAX}| syntax error during precompilation.} | 2743 | @item{@defid{LUA_ERRSYNTAX}| syntax error during precompilation |
2744 | or format error in a binary chunk.} | ||
2740 | 2745 | ||
2741 | @item{@defid{LUA_YIELD}| the thread (coroutine) yields.} | 2746 | @item{@defid{LUA_YIELD}| the thread (coroutine) yields.} |
2742 | 2747 | ||
@@ -3163,8 +3168,6 @@ The index must be the last index previously marked to be closed | |||
3163 | A @idx{__close} metamethod cannot yield | 3168 | A @idx{__close} metamethod cannot yield |
3164 | when called through this function. | 3169 | when called through this function. |
3165 | 3170 | ||
3166 | (This function was introduced in @N{release 5.4.3}.) | ||
3167 | |||
3168 | } | 3171 | } |
3169 | 3172 | ||
3170 | @APIEntry{int lua_closethread (lua_State *L, lua_State *from);| | 3173 | @APIEntry{int lua_closethread (lua_State *L, lua_State *from);| |
@@ -3184,8 +3187,6 @@ The parameter @id{from} represents the coroutine that is resetting @id{L}. | |||
3184 | If there is no such coroutine, | 3187 | If there is no such coroutine, |
3185 | this parameter can be @id{NULL}. | 3188 | this parameter can be @id{NULL}. |
3186 | 3189 | ||
3187 | (This function was introduced in @N{release 5.4.6}.) | ||
3188 | |||
3189 | } | 3190 | } |
3190 | 3191 | ||
3191 | @APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);| | 3192 | @APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);| |
@@ -3233,11 +3234,11 @@ Values at other positions are not affected. | |||
3233 | 3234 | ||
3234 | } | 3235 | } |
3235 | 3236 | ||
3236 | @APIEntry{void lua_createtable (lua_State *L, int narr, int nrec);| | 3237 | @APIEntry{void lua_createtable (lua_State *L, int nseq, int nrec);| |
3237 | @apii{0,1,m} | 3238 | @apii{0,1,m} |
3238 | 3239 | ||
3239 | Creates a new empty table and pushes it onto the stack. | 3240 | Creates a new empty table and pushes it onto the stack. |
3240 | Parameter @id{narr} is a hint for how many elements the table | 3241 | Parameter @id{nseq} is a hint for how many elements the table |
3241 | will have as a sequence; | 3242 | will have as a sequence; |
3242 | parameter @id{nrec} is a hint for how many other elements | 3243 | parameter @id{nrec} is a hint for how many other elements |
3243 | the table will have. | 3244 | the table will have. |
@@ -3264,6 +3265,13 @@ As it produces parts of the chunk, | |||
3264 | with the given @id{data} | 3265 | with the given @id{data} |
3265 | to write them. | 3266 | to write them. |
3266 | 3267 | ||
3268 | The function @Lid{lua_dump} fully preserves the Lua stack | ||
3269 | through the calls to the writer function, | ||
3270 | except that it may push some values for internal use | ||
3271 | before the first call, | ||
3272 | and it restores the stack size to its original size | ||
3273 | after the last call. | ||
3274 | |||
3267 | If @id{strip} is true, | 3275 | If @id{strip} is true, |
3268 | the binary representation may not include all debug information | 3276 | the binary representation may not include all debug information |
3269 | about the function, | 3277 | about the function, |
@@ -3273,8 +3281,6 @@ The value returned is the error code returned by the last | |||
3273 | call to the writer; | 3281 | call to the writer; |
3274 | @N{0 means} no errors. | 3282 | @N{0 means} no errors. |
3275 | 3283 | ||
3276 | This function does not pop the Lua function from the stack. | ||
3277 | |||
3278 | } | 3284 | } |
3279 | 3285 | ||
3280 | @APIEntry{int lua_error (lua_State *L);| | 3286 | @APIEntry{int lua_error (lua_State *L);| |
@@ -3299,50 +3305,62 @@ For options that need extra arguments, | |||
3299 | they are listed after the option. | 3305 | they are listed after the option. |
3300 | @description{ | 3306 | @description{ |
3301 | 3307 | ||
3302 | @item{@id{LUA_GCCOLLECT}| | 3308 | @item{@defid{LUA_GCCOLLECT}| |
3303 | Performs a full garbage-collection cycle. | 3309 | Performs a full garbage-collection cycle. |
3304 | } | 3310 | } |
3305 | 3311 | ||
3306 | @item{@id{LUA_GCSTOP}| | 3312 | @item{@defid{LUA_GCSTOP}| |
3307 | Stops the garbage collector. | 3313 | Stops the garbage collector. |
3308 | } | 3314 | } |
3309 | 3315 | ||
3310 | @item{@id{LUA_GCRESTART}| | 3316 | @item{@defid{LUA_GCRESTART}| |
3311 | Restarts the garbage collector. | 3317 | Restarts the garbage collector. |
3312 | } | 3318 | } |
3313 | 3319 | ||
3314 | @item{@id{LUA_GCCOUNT}| | 3320 | @item{@defid{LUA_GCCOUNT}| |
3315 | Returns the current amount of memory (in Kbytes) in use by Lua. | 3321 | Returns the current amount of memory (in Kbytes) in use by Lua. |
3316 | } | 3322 | } |
3317 | 3323 | ||
3318 | @item{@id{LUA_GCCOUNTB}| | 3324 | @item{@defid{LUA_GCCOUNTB}| |
3319 | Returns the remainder of dividing the current amount of bytes of | 3325 | Returns the remainder of dividing the current amount of bytes of |
3320 | memory in use by Lua by 1024. | 3326 | memory in use by Lua by 1024. |
3321 | } | 3327 | } |
3322 | 3328 | ||
3323 | @item{@id{LUA_GCSTEP} @T{(int stepsize)}| | 3329 | @item{@defid{LUA_GCSTEP} (int n)| |
3324 | Performs an incremental step of garbage collection, | 3330 | Performs a step of garbage collection. |
3325 | corresponding to the allocation of @id{stepsize} Kbytes. | ||
3326 | } | 3331 | } |
3327 | 3332 | ||
3328 | @item{@id{LUA_GCISRUNNING}| | 3333 | @item{@defid{LUA_GCISRUNNING}| |
3329 | Returns a boolean that tells whether the collector is running | 3334 | Returns a boolean that tells whether the collector is running |
3330 | (i.e., not stopped). | 3335 | (i.e., not stopped). |
3331 | } | 3336 | } |
3332 | 3337 | ||
3333 | @item{@id{LUA_GCINC} (int pause, int stepmul, stepsize)| | 3338 | @item{@defid{LUA_GCINC}| |
3334 | Changes the collector to incremental mode | 3339 | Changes the collector to incremental mode. |
3335 | with the given parameters @see{incmode}. | ||
3336 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). | 3340 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). |
3337 | } | 3341 | } |
3338 | 3342 | ||
3339 | @item{@id{LUA_GCGEN} (int minormul, int majormul)| | 3343 | @item{@defid{LUA_GCGEN}| |
3340 | Changes the collector to generational mode | 3344 | Changes the collector to generational mode. |
3341 | with the given parameters @see{genmode}. | ||
3342 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). | 3345 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). |
3343 | } | 3346 | } |
3344 | 3347 | ||
3348 | @item{@defid{LUA_GCPARAM} (int param, int val)| | ||
3349 | Changes and/or returns the value of a parameter of the collector. | ||
3350 | If @id{val} is negative, the call only returns the current value. | ||
3351 | The argument @id{param} must have one of the following values: | ||
3352 | @description{ | ||
3353 | @item{@defid{LUA_GCPMINORMUL}| The minor multiplier. } | ||
3354 | @item{@defid{LUA_GCPMAJORMINOR}| The major-minor multiplier. } | ||
3355 | @item{@defid{LUA_GCPMINORMAJOR}| The minor-major multiplier. } | ||
3356 | @item{@defid{LUA_GCPPAUSE}| The garbage-collector pause. } | ||
3357 | @item{@defid{LUA_GCPSTEPMUL}| The step multiplier. } | ||
3358 | @item{@defid{LUA_GCPSTEPSIZE}| The step size. } | ||
3359 | } | ||
3360 | } | ||
3361 | |||
3345 | } | 3362 | } |
3363 | |||
3346 | For more details about these options, | 3364 | For more details about these options, |
3347 | see @Lid{collectgarbage}. | 3365 | see @Lid{collectgarbage}. |
3348 | 3366 | ||
@@ -3652,10 +3670,27 @@ and loads it accordingly (see program @idx{luac}). | |||
3652 | The string @id{mode} works as in function @Lid{load}, | 3670 | The string @id{mode} works as in function @Lid{load}, |
3653 | with the addition that | 3671 | with the addition that |
3654 | a @id{NULL} value is equivalent to the string @St{bt}. | 3672 | a @id{NULL} value is equivalent to the string @St{bt}. |
3655 | 3673 | Moreover, it may have a @Char{B} instead of a @Char{b}, | |
3656 | @id{lua_load} uses the stack internally, | 3674 | meaning a @emphx{fixed buffer} with the binary dump. |
3657 | so the reader function must always leave the stack | 3675 | |
3658 | unmodified when returning. | 3676 | A fixed buffer means that the address returned by the reader function |
3677 | will contain the chunk until everything created by the chunk has | ||
3678 | been collected; | ||
3679 | therefore, Lua can avoid copying to internal structures | ||
3680 | some parts of the chunk. | ||
3681 | (In general, a fixed buffer would keep the chunk | ||
3682 | as its contents until the end of the program, | ||
3683 | for instance with the chunk in ROM.) | ||
3684 | Moreover, for a fixed buffer, | ||
3685 | the reader function should return the entire chunk in the first read. | ||
3686 | (As an example, @Lid{luaL_loadbufferx} does that.) | ||
3687 | |||
3688 | The function @Lid{lua_load} fully preserves the Lua stack | ||
3689 | through the calls to the reader function, | ||
3690 | except that it may push some values for internal use | ||
3691 | before the first call, | ||
3692 | and it restores the stack size to its original size plus one | ||
3693 | (for the pushed result) after the last call. | ||
3659 | 3694 | ||
3660 | @id{lua_load} can return | 3695 | @id{lua_load} can return |
3661 | @Lid{LUA_OK}, @Lid{LUA_ERRSYNTAX}, or @Lid{LUA_ERRMEM}. | 3696 | @Lid{LUA_OK}, @Lid{LUA_ERRSYNTAX}, or @Lid{LUA_ERRMEM}. |
@@ -3671,7 +3706,8 @@ Other upvalues are initialized with @nil. | |||
3671 | 3706 | ||
3672 | } | 3707 | } |
3673 | 3708 | ||
3674 | @APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud);| | 3709 | @APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud, |
3710 | unsigned int seed);| | ||
3675 | @apii{0,0,-} | 3711 | @apii{0,0,-} |
3676 | 3712 | ||
3677 | Creates a new independent state and returns its main thread. | 3713 | Creates a new independent state and returns its main thread. |
@@ -3682,6 +3718,8 @@ Lua will do all memory allocation for this state | |||
3682 | through this function @seeF{lua_Alloc}. | 3718 | through this function @seeF{lua_Alloc}. |
3683 | The second argument, @id{ud}, is an opaque pointer that Lua | 3719 | The second argument, @id{ud}, is an opaque pointer that Lua |
3684 | passes to the allocator in every call. | 3720 | passes to the allocator in every call. |
3721 | The third argument, @id{seed}, is a seed for the hashing of | ||
3722 | strings when they are used as table keys. | ||
3685 | 3723 | ||
3686 | } | 3724 | } |
3687 | 3725 | ||
@@ -3898,6 +3936,40 @@ This function is equivalent to @Lid{lua_pushcclosure} with no upvalues. | |||
3898 | 3936 | ||
3899 | } | 3937 | } |
3900 | 3938 | ||
3939 | @APIEntry{const char *(lua_pushextlstring) (lua_State *L, | ||
3940 | const char *s, size_t len, lua_Alloc falloc, void *ud);| | ||
3941 | @apii{0,1,m} | ||
3942 | |||
3943 | Creates an @emphx{external string}, | ||
3944 | that is, a string that uses memory not managed by Lua. | ||
3945 | The pointer @id{s} points to the exernal buffer | ||
3946 | holding the string content, | ||
3947 | and @id{len} is the length of the string. | ||
3948 | The string should have a zero at its end, | ||
3949 | that is, the condition @T{s[len] == '\0'} should hold. | ||
3950 | |||
3951 | If @id{falloc} is different from @id{NULL}, | ||
3952 | that function will be called by Lua | ||
3953 | when the external buffer is no longer needed. | ||
3954 | The contents of the buffer should not change before this call. | ||
3955 | The function will be called with the given @id{ud}, | ||
3956 | the string @id{s} as the block, | ||
3957 | the length plus one (to account for the ending zero) as the old size, | ||
3958 | and 0 as the new size. | ||
3959 | |||
3960 | Lua always @x{internalizes} strings with lengths up to 40 characters. | ||
3961 | So, for strings in that range, | ||
3962 | this function will immediately internalize the string | ||
3963 | and call @id{falloc} to free the buffer. | ||
3964 | |||
3965 | Even when using an external buffer, | ||
3966 | Lua still has to allocate a header for the string. | ||
3967 | In case of a memory-allocation error, | ||
3968 | Lua will call @id{falloc} before raising the error. | ||
3969 | |||
3970 | } | ||
3971 | |||
3972 | |||
3901 | @APIEntry{const char *lua_pushfstring (lua_State *L, const char *fmt, ...);| | 3973 | @APIEntry{const char *lua_pushfstring (lua_State *L, const char *fmt, ...);| |
3902 | @apii{0,1,v} | 3974 | @apii{0,1,v} |
3903 | 3975 | ||
@@ -4181,14 +4253,6 @@ and then pops the top element. | |||
4181 | 4253 | ||
4182 | } | 4254 | } |
4183 | 4255 | ||
4184 | @APIEntry{int lua_resetthread (lua_State *L);| | ||
4185 | @apii{0,?,-} | ||
4186 | |||
4187 | This function is deprecated; | ||
4188 | it is equivalent to @Lid{lua_closethread} with | ||
4189 | @id{from} being @id{NULL}. | ||
4190 | |||
4191 | } | ||
4192 | 4256 | ||
4193 | @APIEntry{int lua_resume (lua_State *L, lua_State *from, int nargs, | 4257 | @APIEntry{int lua_resume (lua_State *L, lua_State *from, int nargs, |
4194 | int *nresults);| | 4258 | int *nresults);| |
@@ -4470,8 +4534,6 @@ indicates whether the operation succeeded. | |||
4470 | @apii{0,0,m} | 4534 | @apii{0,0,m} |
4471 | 4535 | ||
4472 | Converts the Lua value at the given index to a @N{C string}. | 4536 | Converts the Lua value at the given index to a @N{C string}. |
4473 | If @id{len} is not @id{NULL}, | ||
4474 | it sets @T{*len} with the string length. | ||
4475 | The Lua value must be a string or a number; | 4537 | The Lua value must be a string or a number; |
4476 | otherwise, the function returns @id{NULL}. | 4538 | otherwise, the function returns @id{NULL}. |
4477 | If the value is a number, | 4539 | If the value is a number, |
@@ -4480,15 +4542,19 @@ then @id{lua_tolstring} also | |||
4480 | (This change confuses @Lid{lua_next} | 4542 | (This change confuses @Lid{lua_next} |
4481 | when @id{lua_tolstring} is applied to keys during a table traversal.) | 4543 | when @id{lua_tolstring} is applied to keys during a table traversal.) |
4482 | 4544 | ||
4483 | @id{lua_tolstring} returns a pointer | 4545 | If @id{len} is not @id{NULL}, |
4484 | to a string inside the Lua state @see{constchar}. | 4546 | the function sets @T{*len} with the string length. |
4485 | This string always has a zero (@Char{\0}) | 4547 | The returned @N{C string} always has a zero (@Char{\0}) |
4486 | after its last character (as @N{in C}), | 4548 | after its last character, |
4487 | but can contain other zeros in its body. | 4549 | but can contain other zeros in its body. |
4488 | 4550 | ||
4551 | The pointer returned by @id{lua_tolstring} | ||
4552 | may be invalidated by the garbage collector if the | ||
4553 | corresponding Lua value is removed from the stack @see{constchar}. | ||
4554 | |||
4489 | This function can raise memory errors only | 4555 | This function can raise memory errors only |
4490 | when converting a number to a string | 4556 | when converting a number to a string |
4491 | (as then it has to create a new string). | 4557 | (as then it may have to create a new string). |
4492 | 4558 | ||
4493 | } | 4559 | } |
4494 | 4560 | ||
@@ -4646,6 +4712,10 @@ passing along the buffer to be written (@id{p}), | |||
4646 | its size (@id{sz}), | 4712 | its size (@id{sz}), |
4647 | and the @id{ud} parameter supplied to @Lid{lua_dump}. | 4713 | and the @id{ud} parameter supplied to @Lid{lua_dump}. |
4648 | 4714 | ||
4715 | After @Lid{lua_dump} writes its last piece, | ||
4716 | it will signal that by calling the writer function one more time, | ||
4717 | with a @id{NULL} buffer (and size 0). | ||
4718 | |||
4649 | The writer returns an error code: | 4719 | The writer returns an error code: |
4650 | @N{0 means} no errors; | 4720 | @N{0 means} no errors; |
4651 | any other value means an error and stops @Lid{lua_dump} from | 4721 | any other value means an error and stops @Lid{lua_dump} from |
@@ -5695,6 +5765,8 @@ This function returns the same results as @Lid{lua_load}. | |||
5695 | @id{name} is the chunk name, | 5765 | @id{name} is the chunk name, |
5696 | used for debug information and error messages. | 5766 | used for debug information and error messages. |
5697 | The string @id{mode} works as in the function @Lid{lua_load}. | 5767 | The string @id{mode} works as in the function @Lid{lua_load}. |
5768 | In particular, this function supports mode @Char{B} for | ||
5769 | fixed buffers. | ||
5698 | 5770 | ||
5699 | } | 5771 | } |
5700 | 5772 | ||
@@ -5741,6 +5813,16 @@ it does not run it. | |||
5741 | 5813 | ||
5742 | } | 5814 | } |
5743 | 5815 | ||
5816 | @APIEntry{unsigned int luaL_makeseed (lua_State *L);| | ||
5817 | @apii{0,0,-} | ||
5818 | |||
5819 | Returns a value with a weak attempt for randomness. | ||
5820 | (It produces that value based on the current date and time | ||
5821 | and the address of an internal variable, | ||
5822 | in case the machine has Address Space Layout Randomization.) | ||
5823 | |||
5824 | } | ||
5825 | |||
5744 | 5826 | ||
5745 | @APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);| | 5827 | @APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);| |
5746 | @apii{0,1,m} | 5828 | @apii{0,1,m} |
@@ -5940,11 +6022,21 @@ Creates and returns a @def{reference}, | |||
5940 | in the table at index @id{t}, | 6022 | in the table at index @id{t}, |
5941 | for the object on the top of the stack (and pops the object). | 6023 | for the object on the top of the stack (and pops the object). |
5942 | 6024 | ||
5943 | A reference is a unique integer key. | 6025 | The reference system uses the integer keys of the table. |
5944 | As long as you do not manually add integer keys into the table @id{t}, | 6026 | A reference is a unique integer key; |
5945 | @Lid{luaL_ref} ensures the uniqueness of the key it returns. | 6027 | @Lid{luaL_ref} ensures the uniqueness of the keys it returns. |
6028 | The entry 1 is reserved for internal use. | ||
6029 | Before the first use of @Lid{luaL_ref}, | ||
6030 | the integer keys of the table | ||
6031 | should form a proper sequence (no holes), | ||
6032 | and the value at entry 1 should be false: | ||
6033 | @nil if the sequence is empty, | ||
6034 | @false otherwise. | ||
6035 | You should not manually set integer keys in the table | ||
6036 | after the first use of @Lid{luaL_ref}. | ||
6037 | |||
5946 | You can retrieve an object referred by the reference @id{r} | 6038 | You can retrieve an object referred by the reference @id{r} |
5947 | by calling @T{lua_rawgeti(L, t, r)}. | 6039 | by calling @T{lua_rawgeti(L, t, r)} or @T{lua_geti(L, t, r)}. |
5948 | The function @Lid{luaL_unref} frees a reference. | 6040 | The function @Lid{luaL_unref} frees a reference. |
5949 | 6041 | ||
5950 | If the object on the top of the stack is @nil, | 6042 | If the object on the top of the stack is @nil, |
@@ -6110,8 +6202,8 @@ Returns the name of the type of the value at the given index. | |||
6110 | Releases the reference @id{ref} from the table at index @id{t} | 6202 | Releases the reference @id{ref} from the table at index @id{t} |
6111 | @seeC{luaL_ref}. | 6203 | @seeC{luaL_ref}. |
6112 | The entry is removed from the table, | 6204 | The entry is removed from the table, |
6113 | so that the referred object can be collected. | 6205 | so that the referred object can be collected and |
6114 | The reference @id{ref} is also freed to be used again. | 6206 | the reference @id{ref} can be used again by @Lid{luaL_ref}. |
6115 | 6207 | ||
6116 | If @id{ref} is @Lid{LUA_NOREF} or @Lid{LUA_REFNIL}, | 6208 | If @id{ref} is @Lid{LUA_NOREF} or @Lid{LUA_REFNIL}, |
6117 | @Lid{luaL_unref} does nothing. | 6209 | @Lid{luaL_unref} does nothing. |
@@ -6268,13 +6360,25 @@ gives the exact number of bytes in use by Lua. | |||
6268 | 6360 | ||
6269 | @item{@St{step}| | 6361 | @item{@St{step}| |
6270 | Performs a garbage-collection step. | 6362 | Performs a garbage-collection step. |
6271 | The step @Q{size} is controlled by @id{arg}. | 6363 | This option may be followed by an extra argument, |
6272 | With a zero value, | 6364 | an integer with the step size. |
6273 | the collector will perform one basic (indivisible) step. | 6365 | The default for this argument is zero. |
6274 | For non-zero values, | 6366 | |
6275 | the collector will perform as if that amount of memory | 6367 | If the size is a positive @id{n}, |
6276 | (in Kbytes) had been allocated by Lua. | 6368 | the collector acts as if @id{n} new objects have been created. |
6277 | Returns @true if the step finished a collection cycle. | 6369 | If the size is zero, |
6370 | the collector performs a basic step. | ||
6371 | In incremental mode, | ||
6372 | a basic step corresponds to the current step size. | ||
6373 | In generational mode, | ||
6374 | a basic step performs a full minor collection or | ||
6375 | a major collection, | ||
6376 | if the collector has scheduled one. | ||
6377 | |||
6378 | In incremental mode, | ||
6379 | the function returns @true if the step finished a collection cycle. | ||
6380 | In generational mode, | ||
6381 | the function returns @true if the step performed a major collection. | ||
6278 | } | 6382 | } |
6279 | 6383 | ||
6280 | @item{@St{isrunning}| | 6384 | @item{@St{isrunning}| |
@@ -6283,20 +6387,34 @@ Returns a boolean that tells whether the collector is running | |||
6283 | } | 6387 | } |
6284 | 6388 | ||
6285 | @item{@St{incremental}| | 6389 | @item{@St{incremental}| |
6286 | Change the collector mode to incremental. | 6390 | Changes the collector mode to incremental and returns the previous mode. |
6287 | This option can be followed by three numbers: | ||
6288 | the garbage-collector pause, | ||
6289 | the step multiplier, | ||
6290 | and the step size @see{incmode}. | ||
6291 | A zero means to not change that value. | ||
6292 | } | 6391 | } |
6293 | 6392 | ||
6294 | @item{@St{generational}| | 6393 | @item{@St{generational}| |
6295 | Change the collector mode to generational. | 6394 | Changes the collector mode to generational and returns the previous mode. |
6296 | This option can be followed by two numbers: | 6395 | } |
6297 | the garbage-collector minor multiplier | 6396 | |
6298 | and the major multiplier @see{genmode}. | 6397 | @item{@St{param}| |
6299 | A zero means to not change that value. | 6398 | Changes and/or retrieves the values of a parameter of the collector. |
6399 | This option must be followed by one or two extra arguments: | ||
6400 | The name of the parameter being changed or retrieved (a string) | ||
6401 | and an optional new value for that parameter (an integer). | ||
6402 | The first argument must have one of the following values: | ||
6403 | @description{ | ||
6404 | @item{@St{minormul}| The minor multiplier. } | ||
6405 | @item{@St{majorminor}| The major-minor multiplier. } | ||
6406 | @item{@St{minormajor}| The minor-major multiplier. } | ||
6407 | @item{@St{pause}| The garbage-collector pause. } | ||
6408 | @item{@St{stepmul}| The step multiplier. } | ||
6409 | @item{@St{stepsize}| The step size. } | ||
6410 | } | ||
6411 | The call always returns the previous value of the parameter. | ||
6412 | If the call does not give a new value, | ||
6413 | the value is left unchanged. | ||
6414 | |||
6415 | Lua rounds these values before storing them; | ||
6416 | so, the value returned as the previous value may not be | ||
6417 | exactly the last value set. | ||
6300 | } | 6418 | } |
6301 | 6419 | ||
6302 | } | 6420 | } |
@@ -6913,9 +7031,9 @@ including if necessary a path and an extension. | |||
6913 | (which may depend on the @N{C compiler} and linker used). | 7031 | (which may depend on the @N{C compiler} and linker used). |
6914 | 7032 | ||
6915 | This functionality is not supported by @N{ISO C}. | 7033 | This functionality is not supported by @N{ISO C}. |
6916 | As such, it is only available on some platforms | 7034 | As such, @id{loadlib} is only available on some platforms: |
6917 | (Windows, Linux, Mac OS X, Solaris, BSD, | 7035 | Linux, Windows, Mac OS X, Solaris, BSD, |
6918 | plus other Unix systems that support the @id{dlfcn} standard). | 7036 | plus other Unix systems that support the @id{dlfcn} standard. |
6919 | 7037 | ||
6920 | This function is inherently insecure, | 7038 | This function is inherently insecure, |
6921 | as it allows Lua to call any function in any readable dynamic | 7039 | as it allows Lua to call any function in any readable dynamic |
@@ -7855,6 +7973,19 @@ If @id{i} is greater than @id{j}, returns the empty string. | |||
7855 | 7973 | ||
7856 | } | 7974 | } |
7857 | 7975 | ||
7976 | @LibEntry{table.create (nseq [, nrec])| | ||
7977 | |||
7978 | Creates a new empty table, preallocating memory. | ||
7979 | This preallocation may help performance and save memory | ||
7980 | when you know in advance how many elements the table will have. | ||
7981 | |||
7982 | Parameter @id{nseq} is a hint for how many elements the table | ||
7983 | will have as a sequence. | ||
7984 | Optional parameter @id{nrec} is a hint for how many other elements | ||
7985 | the table will have; its default is zero. | ||
7986 | |||
7987 | } | ||
7988 | |||
7858 | @LibEntry{table.insert (list, [pos,] value)| | 7989 | @LibEntry{table.insert (list, [pos,] value)| |
7859 | 7990 | ||
7860 | Inserts element @id{value} at position @id{pos} in @id{list}, | 7991 | Inserts element @id{value} at position @id{pos} in @id{list}, |
@@ -8113,7 +8244,7 @@ different sequences of results each time the program runs. | |||
8113 | 8244 | ||
8114 | When called with at least one argument, | 8245 | When called with at least one argument, |
8115 | the integer parameters @id{x} and @id{y} are | 8246 | the integer parameters @id{x} and @id{y} are |
8116 | joined into a 128-bit @emphx{seed} that | 8247 | joined into a @emphx{seed} that |
8117 | is used to reinitialize the pseudo-random generator; | 8248 | is used to reinitialize the pseudo-random generator; |
8118 | equal seeds produce equal sequences of numbers. | 8249 | equal seeds produce equal sequences of numbers. |
8119 | The default for @id{y} is zero. | 8250 | The default for @id{y} is zero. |
@@ -9009,7 +9140,6 @@ The options are: | |||
9009 | @item{@T{--}| stop handling options;} | 9140 | @item{@T{--}| stop handling options;} |
9010 | @item{@T{-}| execute @id{stdin} as a file and stop handling options.} | 9141 | @item{@T{-}| execute @id{stdin} as a file and stop handling options.} |
9011 | } | 9142 | } |
9012 | (The form @T{-l @rep{g=mod}} was introduced in @N{release 5.4.4}.) | ||
9013 | 9143 | ||
9014 | After handling its options, @id{lua} runs the given @emph{script}. | 9144 | After handling its options, @id{lua} runs the given @emph{script}. |
9015 | When called without arguments, | 9145 | When called without arguments, |
@@ -9136,7 +9266,7 @@ is a more portable solution. | |||
9136 | @simplesect{ | 9266 | @simplesect{ |
9137 | 9267 | ||
9138 | Here we list the incompatibilities that you may find when moving a program | 9268 | Here we list the incompatibilities that you may find when moving a program |
9139 | from @N{Lua 5.3} to @N{Lua 5.4}. | 9269 | from @N{Lua 5.4} to @N{Lua 5.5}. |
9140 | 9270 | ||
9141 | You can avoid some incompatibilities by compiling Lua with | 9271 | You can avoid some incompatibilities by compiling Lua with |
9142 | appropriate options (see file @id{luaconf.h}). | 9272 | appropriate options (see file @id{luaconf.h}). |
@@ -9173,51 +9303,9 @@ change between versions. | |||
9173 | @itemize{ | 9303 | @itemize{ |
9174 | 9304 | ||
9175 | @item{ | 9305 | @item{ |
9176 | The coercion of strings to numbers in | 9306 | The control variable in @Rw{for} loops are read only. |
9177 | arithmetic and bitwise operations | 9307 | If you need to change it, |
9178 | has been removed from the core language. | 9308 | declare a local variable with the same name in the loop body. |
9179 | The string library does a similar job | ||
9180 | for arithmetic (but not for bitwise) operations | ||
9181 | using the string metamethods. | ||
9182 | However, unlike in previous versions, | ||
9183 | the new implementation preserves the implicit type of the numeral | ||
9184 | in the string. | ||
9185 | For instance, the result of @T{"1" + "2"} now is an integer, | ||
9186 | not a float. | ||
9187 | } | ||
9188 | |||
9189 | @item{ | ||
9190 | Literal decimal integer constants that overflow are read as floats, | ||
9191 | instead of wrapping around. | ||
9192 | You can use hexadecimal notation for such constants if you | ||
9193 | want the old behavior | ||
9194 | (reading them as integers with wrap around). | ||
9195 | } | ||
9196 | |||
9197 | @item{ | ||
9198 | The use of the @idx{__lt} metamethod to emulate @idx{__le} | ||
9199 | has been removed. | ||
9200 | When needed, this metamethod must be explicitly defined. | ||
9201 | } | ||
9202 | |||
9203 | @item{ | ||
9204 | The semantics of the numerical @Rw{for} loop | ||
9205 | over integers changed in some details. | ||
9206 | In particular, the control variable never wraps around. | ||
9207 | } | ||
9208 | |||
9209 | @item{ | ||
9210 | A label for a @Rw{goto} cannot be declared where a label with the same | ||
9211 | name is visible, even if this other label is declared in an enclosing | ||
9212 | block. | ||
9213 | } | ||
9214 | |||
9215 | @item{ | ||
9216 | When finalizing an object, | ||
9217 | Lua does not ignore @idx{__gc} metamethods that are not functions. | ||
9218 | Any value will be called, if present. | ||
9219 | (Non-callable values will generate a warning, | ||
9220 | like any other error when calling a finalizer.) | ||
9221 | } | 9309 | } |
9222 | 9310 | ||
9223 | } | 9311 | } |
@@ -9228,39 +9316,10 @@ like any other error when calling a finalizer.) | |||
9228 | @itemize{ | 9316 | @itemize{ |
9229 | 9317 | ||
9230 | @item{ | 9318 | @item{ |
9231 | The function @Lid{print} does not call @Lid{tostring} | 9319 | Parameters for the garbage collection are not set |
9232 | to format its arguments; | 9320 | with the options @St{incremental} and @St{generational}; |
9233 | instead, it has this functionality hardwired. | 9321 | instead, there is a new option @St{param} to that end. |
9234 | You should use @idx{__tostring} to modify how values are printed. | 9322 | Moreover, there were some changes in the parameters themselves. |
9235 | } | ||
9236 | |||
9237 | @item{ | ||
9238 | The pseudo-random number generator used by the function @Lid{math.random} | ||
9239 | now starts with a somewhat random seed. | ||
9240 | Moreover, it uses a different algorithm. | ||
9241 | } | ||
9242 | |||
9243 | @item{ | ||
9244 | By default, the decoding functions in the @Lid{utf8} library | ||
9245 | do not accept surrogates as valid code points. | ||
9246 | An extra parameter in these functions makes them more permissive. | ||
9247 | } | ||
9248 | |||
9249 | @item{ | ||
9250 | The options @St{setpause} and @St{setstepmul} | ||
9251 | of the function @Lid{collectgarbage} are deprecated. | ||
9252 | You should use the new option @St{incremental} to set them. | ||
9253 | } | ||
9254 | |||
9255 | @item{ | ||
9256 | The function @Lid{io.lines} now returns four values, | ||
9257 | instead of just one. | ||
9258 | That can be a problem when it is used as the sole | ||
9259 | argument to another function that has optional parameters, | ||
9260 | such as in @T{load(io.lines(filename, "L"))}. | ||
9261 | To fix that issue, | ||
9262 | you can wrap the call into parentheses, | ||
9263 | to adjust its number of results to one. | ||
9264 | } | 9323 | } |
9265 | 9324 | ||
9266 | } | 9325 | } |
@@ -9272,46 +9331,24 @@ to adjust its number of results to one. | |||
9272 | @itemize{ | 9331 | @itemize{ |
9273 | 9332 | ||
9274 | @item{ | 9333 | @item{ |
9275 | Full userdata now has an arbitrary number of associated user values. | 9334 | The function @id{lua_resetthread} is deprecated; |
9276 | Therefore, the functions @id{lua_newuserdata}, | 9335 | it is equivalent to @Lid{lua_closethread} with |
9277 | @id{lua_setuservalue}, and @id{lua_getuservalue} were | 9336 | @id{from} being @id{NULL}. |
9278 | replaced by @Lid{lua_newuserdatauv}, | ||
9279 | @Lid{lua_setiuservalue}, and @Lid{lua_getiuservalue}, | ||
9280 | which have an extra argument. | ||
9281 | |||
9282 | For compatibility, the old names still work as macros assuming | ||
9283 | one single user value. | ||
9284 | Note, however, that userdata with zero user values | ||
9285 | are more efficient memory-wise. | ||
9286 | } | ||
9287 | |||
9288 | @item{ | ||
9289 | The function @Lid{lua_resume} has an extra parameter. | ||
9290 | This out parameter returns the number of values on | ||
9291 | the top of the stack that were yielded or returned by the coroutine. | ||
9292 | (In previous versions, | ||
9293 | those values were the entire stack.) | ||
9294 | } | ||
9295 | |||
9296 | @item{ | ||
9297 | The function @Lid{lua_version} returns the version number, | ||
9298 | instead of an address of the version number. | ||
9299 | The Lua core should work correctly with libraries using their | ||
9300 | own static copies of the same core, | ||
9301 | so there is no need to check whether they are using the same | ||
9302 | address space. | ||
9303 | } | 9337 | } |
9304 | 9338 | ||
9305 | @item{ | 9339 | @item{ |
9306 | The constant @id{LUA_ERRGCMM} was removed. | 9340 | The function @Lid{lua_dump} changed the way it keeps the stack |
9307 | Errors in finalizers are never propagated; | 9341 | through the calls to the writer function. |
9308 | instead, they generate a warning. | 9342 | (That was not specified in previous versions.) |
9343 | Also, it calls the writer function one extra time, | ||
9344 | to signal the end of the dump. | ||
9309 | } | 9345 | } |
9310 | 9346 | ||
9311 | @item{ | 9347 | @item{ |
9312 | The options @idx{LUA_GCSETPAUSE} and @idx{LUA_GCSETSTEPMUL} | 9348 | Parameters for the garbage collection are not set |
9313 | of the function @Lid{lua_gc} are deprecated. | 9349 | with the options @Lid{LUA_GCINC} and @Lid{LUA_GCGEN}; |
9314 | You should use the new option @id{LUA_GCINC} to set them. | 9350 | instead, there is a new option @Lid{LUA_GCPARAM} to that end. |
9351 | Moreover, there were some changes in the parameters themselves. | ||
9315 | } | 9352 | } |
9316 | 9353 | ||
9317 | } | 9354 | } |