lua-users home
lua-l archive

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


> PiL says:
> 
>  "When a C function receives a string argument from Lua, there are
> only two rules that it must observe: Not to pop the string from the
> stack while accessing it and never to modify the string."
> 
> lua.c (5.1.5) does:
> 
> [...]
>   p = lua_tostring(L, -1);
>   [...]
>   lua_pop(L, 1);  /* remove global */
>   return p;
> }
> 
> So what's up here? It looks to me like this code must rely on the fact
> that the _PROMPT global is guaranteed not to be modified or garbage
> collected between accessing it and using p. Is this the case, and if
> so is it considered a good idea to do this kind of thing?

No, this is not a good idea... We should change that code. Thanks for
the remark.

-- Roberto