lua-users home
lua-l archive

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


You're right, I was considering this too, and it would probably be a
good compromise. And obviously easier than implementing a completely
new data type, though I might implement it both ways as an exercise,
to see the differences (it seems that implementing a new "light
userdata"-like data type won't be that hard after all). I'd still need
one userdata per "virtual module", but that's better than having one
_table_ per "virtual module". My new datatype would need just a
pointer per "virtual module", but I'd go with a standard solution if
the memory savings aren't that important (and they probably aren't).

Thanks,
Bogdan

>
> Why don't you use userdata as modules ? IIRC modules don't have to be
> tables. Your userdata would be zero-sized (or eventually have a simple
> pointer to read-only memory), and could share a single metatable,
> since the userdata itself would be passed as first argument of __index
> to let you determine which module is currently indexed.