lua-users home
lua-l archive

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

On Tuesday, April 18, 2006 Roberto Ierusalimschy wrote: 

> We have no intention of allowing userdata addresses to change during
> GC. Unlike strings, which are an internal data in Lua, the only
> purpose of userdata is to be used by C code, which prefer that
> things stay where they are :)

There is a similar, though much less common issue with threads. For
example, C libraries designed for Lua may need to pass callbacks to
external libraries; these callbacks must reference the thread that
created them. Must the C callback's "closure" be regenerated each time
it's used, or can we assume that the thread handle (L) will not change
for the life of the library?

Another example will be in my Lua gem re: per thread library context
and caching. While I know it is safe in Lua 5.1 to use the thread as a
key in a C-side cache, will it be safe to rely on this in the future?


Doug Currie
Londonderry, NH, USA