diff options
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/manual/manual.of b/manual/manual.of index c5385258..09297a63 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -3095,6 +3095,18 @@ will probably need to close states as soon as they are not needed. | |||
3095 | 3095 | ||
3096 | } | 3096 | } |
3097 | 3097 | ||
3098 | @APIEntry{void lua_closeslot (lua_State *L, int index);| | ||
3099 | @apii{0,0,e} | ||
3100 | |||
3101 | Close the to-be-closed slot at the given index and set its value to @nil. | ||
3102 | The index must be the last index previously marked to be closed | ||
3103 | @see{lua_toclose} that is still active (that is, not closed yet). | ||
3104 | |||
3105 | (Exceptionally, this function was introduced in release 5.4.3. | ||
3106 | It is not present in previous 5.4 releases.) | ||
3107 | |||
3108 | } | ||
3109 | |||
3098 | @APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);| | 3110 | @APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);| |
3099 | @apii{0,0,e} | 3111 | @apii{0,0,e} |
3100 | 3112 | ||
@@ -3747,9 +3759,7 @@ except that it allows the called function to yield @see{continuations}. | |||
3747 | @apii{n,0,e} | 3759 | @apii{n,0,e} |
3748 | 3760 | ||
3749 | Pops @id{n} elements from the stack. | 3761 | Pops @id{n} elements from the stack. |
3750 | 3762 | It is implemented as a macro over @Lid{lua_settop}. | |
3751 | This function can run arbitrary code when removing an index | ||
3752 | marked as to-be-closed from the stack. | ||
3753 | 3763 | ||
3754 | } | 3764 | } |
3755 | 3765 | ||
@@ -4240,8 +4250,12 @@ If the new top is greater than the old one, | |||
4240 | then the new elements are filled with @nil. | 4250 | then the new elements are filled with @nil. |
4241 | If @id{index} @N{is 0}, then all stack elements are removed. | 4251 | If @id{index} @N{is 0}, then all stack elements are removed. |
4242 | 4252 | ||
4243 | This function can run arbitrary code when removing an index | 4253 | For compatibility reasons, |
4244 | marked as to-be-closed from the stack. | 4254 | this function may close slots marked as to-be-closed @see{lua_toclose}, |
4255 | and therefore it can run arbitrary code. | ||
4256 | You should not rely on this behavior: | ||
4257 | Instead, always close to-be-closed slots explicitly, | ||
4258 | with @Lid{lua_closeslot}, before removing them from the stack. | ||
4245 | 4259 | ||
4246 | } | 4260 | } |
4247 | 4261 | ||
@@ -4337,10 +4351,9 @@ when it goes out of scope. | |||
4337 | Here, in the context of a C function, | 4351 | Here, in the context of a C function, |
4338 | to go out of scope means that the running function returns to Lua, | 4352 | to go out of scope means that the running function returns to Lua, |
4339 | there is an error, | 4353 | there is an error, |
4340 | or the index is removed from the stack through | 4354 | or there is a call to @Lid{lua_closeslot}. |
4341 | @Lid{lua_settop} or @Lid{lua_pop}. | 4355 | An index marked as to-be-closed should neither be removed from the stack |
4342 | An index marked as to-be-closed should not be removed from the stack | 4356 | nor modified before a corresponding call to @Lid{lua_closeslot}. |
4343 | by any other function in the API except @Lid{lua_settop} or @Lid{lua_pop}. | ||
4344 | 4357 | ||
4345 | This function should not be called for an index | 4358 | This function should not be called for an index |
4346 | that is equal to or below an active to-be-closed index. | 4359 | that is equal to or below an active to-be-closed index. |
@@ -4353,7 +4366,7 @@ Note that, both in case of errors and of a regular return, | |||
4353 | by the time the @idx{__close} metamethod runs, | 4366 | by the time the @idx{__close} metamethod runs, |
4354 | the @N{C stack} was already unwound, | 4367 | the @N{C stack} was already unwound, |
4355 | so that any automatic @N{C variable} declared in the calling function | 4368 | so that any automatic @N{C variable} declared in the calling function |
4356 | will be out of scope. | 4369 | (e.g., a buffer) will be out of scope. |
4357 | 4370 | ||
4358 | } | 4371 | } |
4359 | 4372 | ||