lua-users home
lua-l archive

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


Forgive my ignorance if this should be obvious, but why is the API macro...

   lua_newuserdata(L,size)

...expanded into...

   lua_newuserdatauv(L,size,1)

...and not into...

   lua_newuserdatauv(L,size,0)

?

(Userdata “user values” are a new thing in 5.4.)

The Lua sources themselves never use the macro form, always calling lua_newuserdatauv() explicitly instead. And in every such call, the last parameter (number of user values) is always explicitly set to zero, as though zero is the preferred choice for vanilla userdata allocations.

From a glance at the source code I would guess it has something weird to do with garbage collection... but if so, what? And why? What’s with allocating that 1 “user value” slot for userdatas that never use it?