lua-users home
lua-l archive

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




Flyer31 Test <flyer31@googlemail.com>于2022年2月22日 周二20:50写道:
Why don't you just use "normal c userdata", if you want metafunctions?
(I assume that in this case your userdata quite sure is anyway somehow
"more important" / more "heavy"?).

userdata is a GC object , and we don’t need lua manage the lifespan of objects.

For example, we have a game scene graph in C side, only a few objects (when needed) export into lua side. So,not all C object has the lua proxy.

Userdata is only a reference to scene node. We need another (weak) table to cache them. (Scene node pointer-> userdata)

Another usecase is fixed-point number or complex number library. A value type is much cheaper than GC object.






--
http://blog.codingnow.com