lua-users home
lua-l archive

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


2009/9/1 Juris Kalnins <juris@mt.lv>:
> 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.