On 10 January 2011 18:27, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> Well, sure, but the whole point was to (a) avoid the registry, and
> (b) reduce the execution overhead. It is a simple pointer offset to
> convert from the userdata block address to the userdata object. A
> supported lua_pushuserdata (or something like that) would save lots
> complexity compared with using the registry, and avoid use of ad hoc
> undocumented mechanisms.
That would create a whole new world of possibilities for dangling
pointers. Lua has a strong principle of avoiding references that
are not accounted for by the garbage collector.
-- Roberto
Devils advocate.
So if a user does not have a pointer to use for a lightuserdata then the library would effectively force the thing which Lua does not want onto the user? IE the need to create a pointer to use for a userdata which the user then needs to track and could be left dangling, this is pretty much the case with ints returned by luaL_ref.
I guess I just do not understand what the problem is with references (that is not already solved) and what benefit would be had from the possibility of removing them.