[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: custom "mark" function for userdata?
- From: Joshua Haberman <joshua@...>
- Date: Mon, 10 Aug 2009 07:18:53 +0000 (UTC)
Alex Davies <alex.mania <at> iinet.net.au> writes:
>
> I had the same problem when I was just starting out, as it isn't obvious in
> the documentation but Lua allows a table to be associated with a userdata
> and marks it appropriately. So all circularly references are handled
> correctly, something that's hard to do via the registry.
>
> Quick example:
> lua_newuserdata(L, 0);
> lua_newtable(L);
> lua_pushvalue(L, -1);
> lua_setfenv(L, -3);
Thanks for the info Alex! It's true that this is better than putting
stuff in the registry. I would still prefer to avoid having to
construct this per-userdata table at all, but this at least makes it a
little more tolerable.
Josh