[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Do strings move around?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 27 Aug 2020 09:56:27 -0300
> >>>>> "Roberto" == Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
>
> >> What about strings accessed via upvalue pseudo-indexes?
>
> Roberto> They should be valid while the corresponding call is active.
> Roberto> Documenting it is in my "todo" list.
>
> So here's a more tricky case: what if you do lua_tostring on some stack
> index, and then move that stack item while keeping it on the stack (i.e.
> with lua_rotate or one of its many derivatives such as lua_remove)?
The new wording in the manual already covers this case:
When the index is a stack index,
Lua guarantees that the pointer returned by @id{lua_tolstring}
is valid while the value at that index is neither modified nor popped.
When the index is a pseudo-index (an upvalue),
the pointer returned by @id{lua_tolstring}
is valid while the corresponding call is active and
the corresponding upvalue is not modified.
-- Roberto