I’m using userdata for passing things around with metatables in Lua and calling c++. I’m wondering if maybe light userdata can help me with a few problem cases I have.
A light userdata is a void *, but you can’t do anything with it in lua, at least thats my understanding you can just pass it around and back to C somehow – by a function call?.
How do you use a light userdata? If anyone has some use cases they’ve used them for it would help me get my head around them.
tia
I think Programming In Lua explains it quite well:
The page also explains that light userdata is not garbage collected so memory management must be done by your code. It seems to me the use cases are actually fairly limited which is probably why you can’t find many examples. I did find one example: