diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-13 14:33:14 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-13 14:33:14 -0200 |
| commit | bb0185b196773b878f0bf6b6c6a4a01dbf8c2b83 (patch) | |
| tree | fdafab0746428bf051545aca598f5877089b4ba1 | |
| parent | d40cd315f50538e9dbd4362a4763c01527f4eb3a (diff) | |
| download | lua-bb0185b196773b878f0bf6b6c6a4a01dbf8c2b83.tar.gz lua-bb0185b196773b878f0bf6b6c6a4a01dbf8c2b83.tar.bz2 lua-bb0185b196773b878f0bf6b6c6a4a01dbf8c2b83.zip | |
Documentation for to-be-closed variables
| -rw-r--r-- | manual/manual.of | 148 |
1 files changed, 122 insertions, 26 deletions
diff --git a/manual/manual.of b/manual/manual.of index 91ba8c46..f891c33e 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -1448,7 +1448,9 @@ for @rep{var_1}, @Cdots, @rep{var_n} in @rep{explist} do @rep{block} end | |||
| 1448 | is equivalent to the code: | 1448 | is equivalent to the code: |
| 1449 | @verbatim{ | 1449 | @verbatim{ |
| 1450 | do | 1450 | do |
| 1451 | local @rep{f}, @rep{s}, @rep{var} = @rep{explist} | 1451 | local @rep{f}, @rep{s}, @rep{var} |
| 1452 | local *toclose @rep{tbc} = nil | ||
| 1453 | @rep{f}, @rep{s}, @rep{var}, @rep{tbc} = @rep{explist} | ||
| 1452 | while true do | 1454 | while true do |
| 1453 | local @rep{var_1}, @Cdots, @rep{var_n} = @rep{f}(@rep{s}, @rep{var}) | 1455 | local @rep{var_1}, @Cdots, @rep{var_n} = @rep{f}(@rep{s}, @rep{var}) |
| 1454 | if @rep{var_1} == nil then break end | 1456 | if @rep{var_1} == nil then break end |
| @@ -1464,11 +1466,14 @@ Note the following: | |||
| 1464 | @T{@rep{explist}} is evaluated only once. | 1466 | @T{@rep{explist}} is evaluated only once. |
| 1465 | Its results are an @emph{iterator} function, | 1467 | Its results are an @emph{iterator} function, |
| 1466 | a @emph{state}, | 1468 | a @emph{state}, |
| 1467 | and an initial value for the first @emph{iterator variable}. | 1469 | an initial value for the first @emph{iterator variable}, |
| 1470 | and a to-be-closed variable @see{to-be-closed}, | ||
| 1471 | which can be used to release resources when the loop ends. | ||
| 1468 | } | 1472 | } |
| 1469 | 1473 | ||
| 1470 | @item{ | 1474 | @item{ |
| 1471 | @T{@rep{f}}, @T{@rep{s}}, and @T{@rep{var}} are invisible variables. | 1475 | @T{@rep{f}}, @T{@rep{s}}, @T{@rep{var}}, and @T{@rep{tbc}} |
| 1476 | are invisible variables. | ||
| 1472 | The names are here for explanatory purposes only. | 1477 | The names are here for explanatory purposes only. |
| 1473 | } | 1478 | } |
| 1474 | 1479 | ||
| @@ -1515,6 +1520,52 @@ The visibility rules for local variables are explained in @See{visibility}. | |||
| 1515 | 1520 | ||
| 1516 | } | 1521 | } |
| 1517 | 1522 | ||
| 1523 | @sect3{to-be-closed| @title{To-be-closed Variables} | ||
| 1524 | |||
| 1525 | A local variable can be declared as a @def{to-be-closed} variable, | ||
| 1526 | with the following syntax: | ||
| 1527 | @Produc{ | ||
| 1528 | @producname{stat}@producbody{ | ||
| 1529 | @Rw{local} @bnfter{*} @bnfter{toclose} Name @bnfter{=} exp | ||
| 1530 | }} | ||
| 1531 | A to-be-closed variable behaves like a normal local variable, | ||
| 1532 | except that its value is @emph{closed} whenever the variable | ||
| 1533 | goes out of scope, including normal block termination, | ||
| 1534 | exiting its block by @Rw{break}/@Rw{goto}/@Rw{return}, | ||
| 1535 | or exiting by an error. | ||
| 1536 | If a block ends in a tail call @see{functioncall}, | ||
| 1537 | all variables of the caller function go out of scope | ||
| 1538 | before the start of the callee function. | ||
| 1539 | |||
| 1540 | To \emph{close} a value has the following meaning here: | ||
| 1541 | If the value of the variable when it goes out of scope is a function, | ||
| 1542 | that function is called; | ||
| 1543 | otherwise, if the value has a @idx{__close} metamethod, | ||
| 1544 | that metamethod is called; | ||
| 1545 | otherwise, nothing is done. | ||
| 1546 | In the function case, | ||
| 1547 | if the scope is being closed by an error, | ||
| 1548 | the error object is passed as an argument to the function; | ||
| 1549 | if there is no error, the function gets @nil. | ||
| 1550 | In the metamethod case, | ||
| 1551 | the value itself always is passed as an argument to the metamethod. | ||
| 1552 | |||
| 1553 | If several to-be-closed variables go out of scope at the same event, | ||
| 1554 | they are closed in the reverse order that they were declared. | ||
| 1555 | If there is any error while running a closing function, | ||
| 1556 | that error is handled like an error in the regular code | ||
| 1557 | where the variable was defined; | ||
| 1558 | in particular, | ||
| 1559 | the other pending closing functions will still be called. | ||
| 1560 | |||
| 1561 | If a coroutine yields inside a block and is never resumed again, | ||
| 1562 | the variables visible at that block will never go out of scope, | ||
| 1563 | and therefore they will not be closed. | ||
| 1564 | Similarly, if a script is interrupted by an unprotected error, | ||
| 1565 | its to-be-closed variables will not be closed. | ||
| 1566 | |||
| 1567 | } | ||
| 1568 | |||
| 1518 | } | 1569 | } |
| 1519 | 1570 | ||
| 1520 | @sect2{expressions| @title{Expressions} | 1571 | @sect2{expressions| @title{Expressions} |
| @@ -2442,7 +2493,7 @@ the result of @Lid{lua_newthread}), | |||
| 2442 | it should use them only in API calls that cannot raise errors. | 2493 | it should use them only in API calls that cannot raise errors. |
| 2443 | 2494 | ||
| 2444 | The panic function runs as if it were a @x{message handler} @see{error}; | 2495 | The panic function runs as if it were a @x{message handler} @see{error}; |
| 2445 | in particular, the error object is at the top of the stack. | 2496 | in particular, the error object is on the top of the stack. |
| 2446 | However, there is no guarantee about stack space. | 2497 | However, there is no guarantee about stack space. |
| 2447 | To push anything on the stack, | 2498 | To push anything on the stack, |
| 2448 | the panic function must first check the available space @see{stacksize}. | 2499 | the panic function must first check the available space @see{stacksize}. |
| @@ -2593,9 +2644,9 @@ tells whether the function may raise errors: | |||
| 2593 | @Char{m} means the function may raise out-of-memory errors | 2644 | @Char{m} means the function may raise out-of-memory errors |
| 2594 | and errors running a finalizer; | 2645 | and errors running a finalizer; |
| 2595 | @Char{v} means the function may raise the errors explained in the text; | 2646 | @Char{v} means the function may raise the errors explained in the text; |
| 2596 | @Char{e} means the function may raise any errors | 2647 | @Char{e} means the function can run arbitrary Lua code, |
| 2597 | (because it can run arbitrary Lua code, | 2648 | either directly or through metamethods, |
| 2598 | either directly or through metamethods). | 2649 | and therefore may raise any errors. |
| 2599 | 2650 | ||
| 2600 | 2651 | ||
| 2601 | @APIEntry{int lua_absindex (lua_State *L, int idx);| | 2652 | @APIEntry{int lua_absindex (lua_State *L, int idx);| |
| @@ -2675,7 +2726,7 @@ that @T{free(NULL)} has no effect and that | |||
| 2675 | Performs an arithmetic or bitwise operation over the two values | 2726 | Performs an arithmetic or bitwise operation over the two values |
| 2676 | (or one, in the case of negations) | 2727 | (or one, in the case of negations) |
| 2677 | at the top of the stack, | 2728 | at the top of the stack, |
| 2678 | with the value at the top being the second operand, | 2729 | with the value on the top being the second operand, |
| 2679 | pops these values, and pushes the result of the operation. | 2730 | pops these values, and pushes the result of the operation. |
| 2680 | The function follows the semantics of the corresponding Lua operator | 2731 | The function follows the semantics of the corresponding Lua operator |
| 2681 | (that is, it may call metamethods). | 2732 | (that is, it may call metamethods). |
| @@ -2875,7 +2926,7 @@ The value of @id{op} must be one of the following constants: | |||
| 2875 | @apii{n,1,e} | 2926 | @apii{n,1,e} |
| 2876 | 2927 | ||
| 2877 | Concatenates the @id{n} values at the top of the stack, | 2928 | Concatenates the @id{n} values at the top of the stack, |
| 2878 | pops them, and leaves the result at the top. | 2929 | pops them, and leaves the result on the top. |
| 2879 | If @N{@T{n} is 1}, the result is the single value on the stack | 2930 | If @N{@T{n} is 1}, the result is the single value on the stack |
| 2880 | (that is, the function does nothing); | 2931 | (that is, the function does nothing); |
| 2881 | if @id{n} is 0, the result is the empty string. | 2932 | if @id{n} is 0, the result is the empty string. |
| @@ -2942,7 +2993,7 @@ This function does not pop the Lua function from the stack. | |||
| 2942 | @apii{1,0,v} | 2993 | @apii{1,0,v} |
| 2943 | 2994 | ||
| 2944 | Generates a Lua error, | 2995 | Generates a Lua error, |
| 2945 | using the value at the top of the stack as the error object. | 2996 | using the value on the top of the stack as the error object. |
| 2946 | This function does a long jump, | 2997 | This function does a long jump, |
| 2947 | and therefore never returns | 2998 | and therefore never returns |
| 2948 | @seeC{luaL_error}. | 2999 | @seeC{luaL_error}. |
| @@ -3081,7 +3132,7 @@ the function @N{returns 0} and pushes nothing on the stack. | |||
| 3081 | 3132 | ||
| 3082 | Pushes onto the stack the value @T{t[k]}, | 3133 | Pushes onto the stack the value @T{t[k]}, |
| 3083 | where @id{t} is the value at the given index | 3134 | where @id{t} is the value at the given index |
| 3084 | and @id{k} is the value at the top of the stack. | 3135 | and @id{k} is the value on the top of the stack. |
| 3085 | 3136 | ||
| 3086 | This function pops the key from the stack, | 3137 | This function pops the key from the stack, |
| 3087 | pushing the resulting value in its place. | 3138 | pushing the resulting value in its place. |
| @@ -3798,7 +3849,7 @@ Similar to @Lid{lua_settable}, but does a raw assignment | |||
| 3798 | 3849 | ||
| 3799 | Does the equivalent of @T{t[i] = v}, | 3850 | Does the equivalent of @T{t[i] = v}, |
| 3800 | where @id{t} is the table at the given index | 3851 | where @id{t} is the table at the given index |
| 3801 | and @id{v} is the value at the top of the stack. | 3852 | and @id{v} is the value on the top of the stack. |
| 3802 | 3853 | ||
| 3803 | This function pops the value from the stack. | 3854 | This function pops the value from the stack. |
| 3804 | The assignment is raw, | 3855 | The assignment is raw, |
| @@ -3812,7 +3863,7 @@ that is, it does not invoke the @idx{__newindex} metamethod. | |||
| 3812 | Does the equivalent of @T{t[p] = v}, | 3863 | Does the equivalent of @T{t[p] = v}, |
| 3813 | where @id{t} is the table at the given index, | 3864 | where @id{t} is the table at the given index, |
| 3814 | @id{p} is encoded as a light userdata, | 3865 | @id{p} is encoded as a light userdata, |
| 3815 | and @id{v} is the value at the top of the stack. | 3866 | and @id{v} is the value on the top of the stack. |
| 3816 | 3867 | ||
| 3817 | This function pops the value from the stack. | 3868 | This function pops the value from the stack. |
| 3818 | The assignment is raw, | 3869 | The assignment is raw, |
| @@ -3939,7 +3990,7 @@ with user data @id{ud}. | |||
| 3939 | 3990 | ||
| 3940 | Does the equivalent to @T{t[k] = v}, | 3991 | Does the equivalent to @T{t[k] = v}, |
| 3941 | where @id{t} is the value at the given index | 3992 | where @id{t} is the value at the given index |
| 3942 | and @id{v} is the value at the top of the stack. | 3993 | and @id{v} is the value on the top of the stack. |
| 3943 | 3994 | ||
| 3944 | This function pops the value from the stack. | 3995 | This function pops the value from the stack. |
| 3945 | As in Lua, this function may trigger a metamethod | 3996 | As in Lua, this function may trigger a metamethod |
| @@ -3960,7 +4011,7 @@ sets it as the new value of global @id{name}. | |||
| 3960 | 4011 | ||
| 3961 | Does the equivalent to @T{t[n] = v}, | 4012 | Does the equivalent to @T{t[n] = v}, |
| 3962 | where @id{t} is the value at the given index | 4013 | where @id{t} is the value at the given index |
| 3963 | and @id{v} is the value at the top of the stack. | 4014 | and @id{v} is the value on the top of the stack. |
| 3964 | 4015 | ||
| 3965 | This function pops the value from the stack. | 4016 | This function pops the value from the stack. |
| 3966 | As in Lua, this function may trigger a metamethod | 4017 | As in Lua, this function may trigger a metamethod |
| @@ -3981,7 +4032,7 @@ sets it as the new metatable for the value at the given index. | |||
| 3981 | 4032 | ||
| 3982 | Does the equivalent to @T{t[k] = v}, | 4033 | Does the equivalent to @T{t[k] = v}, |
| 3983 | where @id{t} is the value at the given index, | 4034 | where @id{t} is the value at the given index, |
| 3984 | @id{v} is the value at the top of the stack, | 4035 | @id{v} is the value on the top of the stack, |
| 3985 | and @id{k} is the value just below the top. | 4036 | and @id{k} is the value just below the top. |
| 3986 | 4037 | ||
| 3987 | This function pops both the key and the value from the stack. | 4038 | This function pops both the key and the value from the stack. |
| @@ -4082,6 +4133,31 @@ otherwise, returns @id{NULL}. | |||
| 4082 | 4133 | ||
| 4083 | } | 4134 | } |
| 4084 | 4135 | ||
| 4136 | @APIEntry{void lua_toclose (lua_State *L, int index);| | ||
| 4137 | @apii{0,0,v} | ||
| 4138 | |||
| 4139 | Marks the given index in the stack as a | ||
| 4140 | to-be-closed @Q{variable} @see{to-be-closed}. | ||
| 4141 | Like a to-be-closed variable in Lua, | ||
| 4142 | the value at that index in the stack will be closed | ||
| 4143 | when it goes out of scope. | ||
| 4144 | Here, in the context of a C function, | ||
| 4145 | to go out of scope means that the running function returns (to Lua), | ||
| 4146 | there is an error, | ||
| 4147 | or the index is removed from the stack through | ||
| 4148 | @Lid{lua_settop} or @Lid{lua_pop}. | ||
| 4149 | An index marked as to-be-closed should not be removed from the stack | ||
| 4150 | by any other function in the API except @Lid{lua_settop} or @Lid{lua_pop}. | ||
| 4151 | |||
| 4152 | This function should not be called for an index | ||
| 4153 | that is equal to or below an already marked to-be-closed index. | ||
| 4154 | |||
| 4155 | This function can raise an out-of-memory error. | ||
| 4156 | In that case, the value in the given index is immediately closed, | ||
| 4157 | as if it was already marked. | ||
| 4158 | |||
| 4159 | } | ||
| 4160 | |||
| 4085 | @APIEntry{lua_Integer lua_tointeger (lua_State *L, int index);| | 4161 | @APIEntry{lua_Integer lua_tointeger (lua_State *L, int index);| |
| 4086 | @apii{0,0,-} | 4162 | @apii{0,0,-} |
| 4087 | 4163 | ||
| @@ -4587,7 +4663,7 @@ and names. | |||
| 4587 | and returns its name. | 4663 | and returns its name. |
| 4588 | 4664 | ||
| 4589 | In the second case, @id{ar} must be @id{NULL} and the function | 4665 | In the second case, @id{ar} must be @id{NULL} and the function |
| 4590 | to be inspected must be at the top of the stack. | 4666 | to be inspected must be on the top of the stack. |
| 4591 | In this case, only parameters of Lua functions are visible | 4667 | In this case, only parameters of Lua functions are visible |
| 4592 | (as there is no information about what variables are active) | 4668 | (as there is no information about what variables are active) |
| 4593 | and no values are pushed onto the stack. | 4669 | and no values are pushed onto the stack. |
| @@ -4720,7 +4796,7 @@ A hook is disabled by setting @id{mask} to zero. | |||
| 4720 | @apii{0|1,0,-} | 4796 | @apii{0|1,0,-} |
| 4721 | 4797 | ||
| 4722 | Sets the value of a local variable of a given activation record. | 4798 | Sets the value of a local variable of a given activation record. |
| 4723 | It assigns the value at the top of the stack | 4799 | It assigns the value on the top of the stack |
| 4724 | to the variable and returns its name. | 4800 | to the variable and returns its name. |
| 4725 | It also pops the value from the stack. | 4801 | It also pops the value from the stack. |
| 4726 | 4802 | ||
| @@ -4736,7 +4812,7 @@ Parameters @id{ar} and @id{n} are as in function @Lid{lua_getlocal}. | |||
| 4736 | @apii{0|1,0,-} | 4812 | @apii{0|1,0,-} |
| 4737 | 4813 | ||
| 4738 | Sets the value of a closure's upvalue. | 4814 | Sets the value of a closure's upvalue. |
| 4739 | It assigns the value at the top of the stack | 4815 | It assigns the value on the top of the stack |
| 4740 | to the upvalue and returns its name. | 4816 | to the upvalue and returns its name. |
| 4741 | It also pops the value from the stack. | 4817 | It also pops the value from the stack. |
| 4742 | 4818 | ||
| @@ -4861,7 +4937,7 @@ to the buffer @id{B} | |||
| 4861 | @APIEntry{void luaL_addvalue (luaL_Buffer *B);| | 4937 | @APIEntry{void luaL_addvalue (luaL_Buffer *B);| |
| 4862 | @apii{1,?,m} | 4938 | @apii{1,?,m} |
| 4863 | 4939 | ||
| 4864 | Adds the value at the top of the stack | 4940 | Adds the value on the top of the stack |
| 4865 | to the buffer @id{B} | 4941 | to the buffer @id{B} |
| 4866 | @seeC{luaL_Buffer}. | 4942 | @seeC{luaL_Buffer}. |
| 4867 | Pops the value. | 4943 | Pops the value. |
| @@ -5486,7 +5562,7 @@ Equivalent to the sequence @Lid{luaL_addsize}, @Lid{luaL_pushresult}. | |||
| 5486 | 5562 | ||
| 5487 | Creates and returns a @def{reference}, | 5563 | Creates and returns a @def{reference}, |
| 5488 | in the table at index @id{t}, | 5564 | in the table at index @id{t}, |
| 5489 | for the object at the top of the stack (and pops the object). | 5565 | for the object on the top of the stack (and pops the object). |
| 5490 | 5566 | ||
| 5491 | A reference is a unique integer key. | 5567 | A reference is a unique integer key. |
| 5492 | As long as you do not manually add integer keys into table @id{t}, | 5568 | As long as you do not manually add integer keys into table @id{t}, |
| @@ -5495,7 +5571,7 @@ You can retrieve an object referred by reference @id{r} | |||
| 5495 | by calling @T{lua_rawgeti(L, t, r)}. | 5571 | by calling @T{lua_rawgeti(L, t, r)}. |
| 5496 | Function @Lid{luaL_unref} frees a reference and its associated object. | 5572 | Function @Lid{luaL_unref} frees a reference and its associated object. |
| 5497 | 5573 | ||
| 5498 | If the object at the top of the stack is @nil, | 5574 | If the object on the top of the stack is @nil, |
| 5499 | @Lid{luaL_ref} returns the constant @defid{LUA_REFNIL}. | 5575 | @Lid{luaL_ref} returns the constant @defid{LUA_REFNIL}. |
| 5500 | The constant @defid{LUA_NOREF} is guaranteed to be different | 5576 | The constant @defid{LUA_NOREF} is guaranteed to be different |
| 5501 | from any reference returned by @Lid{luaL_ref}. | 5577 | from any reference returned by @Lid{luaL_ref}. |
| @@ -5554,7 +5630,7 @@ These values are popped from the stack after the registration. | |||
| 5554 | @APIEntry{void luaL_setmetatable (lua_State *L, const char *tname);| | 5630 | @APIEntry{void luaL_setmetatable (lua_State *L, const char *tname);| |
| 5555 | @apii{0,0,-} | 5631 | @apii{0,0,-} |
| 5556 | 5632 | ||
| 5557 | Sets the metatable of the object at the top of the stack | 5633 | Sets the metatable of the object on the top of the stack |
| 5558 | as the metatable associated with name @id{tname} | 5634 | as the metatable associated with name @id{tname} |
| 5559 | in the registry @seeC{luaL_newmetatable}. | 5635 | in the registry @seeC{luaL_newmetatable}. |
| 5560 | 5636 | ||
| @@ -7571,6 +7647,9 @@ The table @id{io} also provides | |||
| 7571 | three predefined file handles with their usual meanings from C: | 7647 | three predefined file handles with their usual meanings from C: |
| 7572 | @defid{io.stdin}, @defid{io.stdout}, and @defid{io.stderr}. | 7648 | @defid{io.stdin}, @defid{io.stdout}, and @defid{io.stderr}. |
| 7573 | The I/O library never closes these files. | 7649 | The I/O library never closes these files. |
| 7650 | The metatable for file handles provides metamethods | ||
| 7651 | for @idx{__gc} and @idx{__close} that try | ||
| 7652 | to close the file when called. | ||
| 7574 | 7653 | ||
| 7575 | Unless otherwise stated, | 7654 | Unless otherwise stated, |
| 7576 | all I/O functions return @nil on failure | 7655 | all I/O functions return @nil on failure |
| @@ -7617,6 +7696,13 @@ and returns an iterator function that | |||
| 7617 | works like @T{file:lines(@Cdots)} over the opened file. | 7696 | works like @T{file:lines(@Cdots)} over the opened file. |
| 7618 | When the iterator function detects the end of file, | 7697 | When the iterator function detects the end of file, |
| 7619 | it returns no values (to finish the loop) and automatically closes the file. | 7698 | it returns no values (to finish the loop) and automatically closes the file. |
| 7699 | Besides the iterator function, | ||
| 7700 | @id{io.lines} returns three other values: | ||
| 7701 | two @nil values as placeholders, | ||
| 7702 | plus the created file handle. | ||
| 7703 | Therefore, when used in a generic @Rw{for} loop, | ||
| 7704 | the file is closed also if the loop is interrupted by an | ||
| 7705 | error or a @Rw{break}. | ||
| 7620 | 7706 | ||
| 7621 | The call @T{io.lines()} (with no file name) is equivalent | 7707 | The call @T{io.lines()} (with no file name) is equivalent |
| 7622 | to @T{io.input():lines("l")}; | 7708 | to @T{io.input():lines("l")}; |
| @@ -8543,6 +8629,13 @@ now starts with a somewhat random seed. | |||
| 8543 | Moreover, it uses a different algorithm. | 8629 | Moreover, it uses a different algorithm. |
| 8544 | } | 8630 | } |
| 8545 | 8631 | ||
| 8632 | @item{ | ||
| 8633 | The function @Lid{io.lines} now returns three extra values, | ||
| 8634 | besides the iterator function. | ||
| 8635 | You can enclose the call in parentheses if you need to | ||
| 8636 | discard these extra results. | ||
| 8637 | } | ||
| 8638 | |||
| 8546 | } | 8639 | } |
| 8547 | 8640 | ||
| 8548 | } | 8641 | } |
| @@ -8559,15 +8652,17 @@ replaced by @Lid{lua_newuserdatauv}, | |||
| 8559 | @Lid{lua_setiuservalue}, and @Lid{lua_getiuservalue}, | 8652 | @Lid{lua_setiuservalue}, and @Lid{lua_getiuservalue}, |
| 8560 | which have an extra argument. | 8653 | which have an extra argument. |
| 8561 | 8654 | ||
| 8562 | (For compatibility, the old names still work as macros assuming | 8655 | For compatibility, the old names still work as macros assuming |
| 8563 | one single user value.) | 8656 | one single user value. |
| 8657 | Note, however, that the call @T{lua_newuserdatauv(L,size,0)} | ||
| 8658 | produces a smaller userdata. | ||
| 8564 | } | 8659 | } |
| 8565 | 8660 | ||
| 8566 | @item{ | 8661 | @item{ |
| 8567 | The function @Lid{lua_resume} has an extra parameter. | 8662 | The function @Lid{lua_resume} has an extra parameter. |
| 8568 | This out parameter returns the number of values on | 8663 | This out parameter returns the number of values on |
| 8569 | the top of the stack that were yielded or returned by the coroutine. | 8664 | the top of the stack that were yielded or returned by the coroutine. |
| 8570 | (In older versions, | 8665 | (In previous versions, |
| 8571 | those values were the entire stack.) | 8666 | those values were the entire stack.) |
| 8572 | } | 8667 | } |
| 8573 | 8668 | ||
| @@ -8626,6 +8721,7 @@ and @bnfNter{LiteralString}, see @See{lexical}.) | |||
| 8626 | @OrNL @Rw{function} funcname funcbody | 8721 | @OrNL @Rw{function} funcname funcbody |
| 8627 | @OrNL @Rw{local} @Rw{function} @bnfNter{Name} funcbody | 8722 | @OrNL @Rw{local} @Rw{function} @bnfNter{Name} funcbody |
| 8628 | @OrNL @Rw{local} namelist @bnfopt{@bnfter{=} explist} | 8723 | @OrNL @Rw{local} namelist @bnfopt{@bnfter{=} explist} |
| 8724 | @OrNL @Rw{local} @bnfter{*} @bnfter{toclose} Name @bnfter{=} exp | ||
| 8629 | } | 8725 | } |
| 8630 | 8726 | ||
| 8631 | @producname{retstat}@producbody{@Rw{return} | 8727 | @producname{retstat}@producbody{@Rw{return} |
