lua-users home
lua-l archive

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


> There's no document that I'm aware of that exactly defines the  
> contract between the Lua interpreter and extensions written in C. My  
> assumption has been that any reference to an object will keep the  
> object allocated and in the same location. If that's not true I'd  
> really like to know.

The document that defines the contract between the Lua interpreter and
extensions written in C is the Lua manual. The manual tells (or should
tell, or tries to tell) what is valid. (It would be a really long list
to write down all kinds of invalid things that cannot be done). If you
are "religious", you should not make assumptions that are not written
there.

For strings, the manual says this:

  Because Lua has garbage collection, there is no guarantee that the
  pointer returned by lua_tolstring will be valid after the corresponding
  value is removed from the stack.

(But it does not specify the behavior of userdata...)

-- Roberto