aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of33
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
3101Close the to-be-closed slot at the given index and set its value to @nil.
3102The 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.
3106It 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
3749Pops @id{n} elements from the stack. 3761Pops @id{n} elements from the stack.
3750 3762It is implemented as a macro over @Lid{lua_settop}.
3751This function can run arbitrary code when removing an index
3752marked 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,
4240then the new elements are filled with @nil. 4250then the new elements are filled with @nil.
4241If @id{index} @N{is 0}, then all stack elements are removed. 4251If @id{index} @N{is 0}, then all stack elements are removed.
4242 4252
4243This function can run arbitrary code when removing an index 4253For compatibility reasons,
4244marked as to-be-closed from the stack. 4254this function may close slots marked as to-be-closed @see{lua_toclose},
4255and therefore it can run arbitrary code.
4256You should not rely on this behavior:
4257Instead, always close to-be-closed slots explicitly,
4258with @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.
4337Here, in the context of a C function, 4351Here, in the context of a C function,
4338to go out of scope means that the running function returns to Lua, 4352to go out of scope means that the running function returns to Lua,
4339there is an error, 4353there is an error,
4340or the index is removed from the stack through 4354or there is a call to @Lid{lua_closeslot}.
4341@Lid{lua_settop} or @Lid{lua_pop}. 4355An index marked as to-be-closed should neither be removed from the stack
4342An index marked as to-be-closed should not be removed from the stack 4356nor modified before a corresponding call to @Lid{lua_closeslot}.
4343by any other function in the API except @Lid{lua_settop} or @Lid{lua_pop}.
4344 4357
4345This function should not be called for an index 4358This function should not be called for an index
4346that is equal to or below an active to-be-closed index. 4359that 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,
4353by the time the @idx{__close} metamethod runs, 4366by the time the @idx{__close} metamethod runs,
4354the @N{C stack} was already unwound, 4367the @N{C stack} was already unwound,
4355so that any automatic @N{C variable} declared in the calling function 4368so that any automatic @N{C variable} declared in the calling function
4356will be out of scope. 4369(e.g., a buffer) will be out of scope.
4357 4370
4358} 4371}
4359 4372