lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mon, Feb 1, 2021 at 3:44 PM Egor Skriptunoff
<> wrote:

> This quote doesn't answer my question.

Your question was "Does Lua guarantee debug.upvalueid() returns the
same result during the lifespan of the closure?"

Roberto's answer was negative, with a demonstration.

Apparently that was not really the question you wanted answered. You
rephrased your question:

> Are those hexadecimal digits after "userdata:" permanent?

But the answer to this is trivially negative again, from the same demonstration.

I may have misunderstood, but it looks like you are asking for a full
list of operations that could change a previously seen upvalue ID for
a given contiguously existing chunk.

I do not know the (full) answer, but GC is not part of it, because
Lua's (stock) GC is non-moving, so an address of an existing object
cannot change. I would think that the upvalue join demonstrated by
Roberto, along with its C API counterpart, should be the only such
operation, but somebody more knowledgeable should confirm this.