[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: userdata environment
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Tue, 1 Sep 2009 16:20:48 +0200
2009/9/1 Juris Kalnins <email@example.com>:
> Maual says: << Environments associated with userdata have no meaning for
> Lua. It is only a convenience feature for programmers to associate a table
> to a userdata. >>
> Would it be possible to have Udata->env of type GCObject *?
> It seems quite a waste to allocate table just to attach, say, one string to
> a userdata.
When I first used userdata environment I assumed it was the case and
was quite disappointed to discover it's not.
However you have other methods to associate metadata to a userdata.
For example you can use a weak table in the registry, with the
userdata as a weak key and the string as value.