lua-users home
lua-l archive

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


On Dec 7, 2011, at 7:57 AM, Rebel Neurofog wrote:

> On Wed, Dec 7, 2011 at 7:35 PM, Mark Hamburg <mark@grubmah.com> wrote:
>> On Dec 7, 2011, at 3:09 AM, Rebel Neurofog wrote:
>> 
>>> 1. Putting string into registry will guarantee it's validness during
>>> lua_State lifetime.
>> 
>> This is true of current implementations of Lua but is not guaranteed by the API. It could break, for example, if Lua shifted to a moving collector.
>> 
>> Mark
>> 
>> 
> 
> What do you mean?
> String value will be lost? But then what will I get by accessing registry?
> String value will change? But that's not about collector but string
> hashing. So when should it happen not to ruin C code?
> 
> Please explain it in details. Until now I thought I have clear vision
> about that...

The string will still be in the registry but the character buffer for the string might move which would invalidate the results of lua_tostring. The API only promises that lua_tostring's results will stay valid if the string remains on the stack.

Mark