lua-users home
lua-l archive

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

On 14.01.2011 16:29, Jonathan Castello wrote:
For what it's worth, I like to use debug.setfenv/debug.getfenv with a
newproxy() userdata to store private data with an object from Lua.
There's no way to do this with tables (that I know of) except with a
relatively clunky local table where the keys are objects and the
values are the private data.

The way I came up with is to store the table with private variables in a special key that's skipped by 'next'. The key is a local object, so it can't be found otherwise. I even made the attached script back then, which allows any script to have its own set of private variables in any table. I haven't published it though.

Best regards,
Sergey Rozhenko       

Attachment: RSHidden.lua
Description: luaedit/luaedit.lua