> Thanks, that’s what I needed to know. I can guarantee that references will be preserved, so this isn’t an issue.
If I understand the intent correctly, you would like to use a string returned by Lua after it was popped off the stack, on the account that it had previously been registered.
I would recommend against this. This technique is brittle.
Note that the documentation warns explicitly: "Because Lua has garbage collection, there is no guarantee that the pointer returned by lua_tolstring will be valid after the corresponding Lua value is removed from the stack".
I doubt you will gain much by popping prematurely, but I can guarantee that any eventual bugs will be a royal pain.
Cheers,
V.