lua-users home
lua-l archive

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


On Sun, Apr 20, 2014 at 02:55:38PM +0200, Dirk Laurie wrote:
> 2014-04-20 13:50 GMT+02:00 Peng Zhicheng <pengzhicheng1986@gmail.com>:
> 
> > I feel it too much overhead using the full userdata just to pass some opaque
> > values, and I need to set a per-instance metatable everytime I produced that
> > value.
> 
> Given that you will have a metatable per instance, please explain (more
> concisely than the original post please) just how much overhead relative
> to a full userdata you think you are saving.

While Peng didn't articulate it exactly well in english, the code is
self-explanatory. Metatables are stored once, globally, per tag
"extension" type. Instances are then only tagged accordingly.

I'm using something similiar since Lua 5.1, and a lot of game folk would
welcome official support for this, as it is now, most of us are stuck with
personal kludges.

GC pressure is most common Lua bottleneck, and this is one of the viable
ways to solve it (alternative is to use "ID" API which is more demanding
both on C side, and Lua environment user, but supposedly "cleaner").