Re:Lua, a Misunderstood Language
by viraptor on Friday January 15, 2021 @07:37PM
(#25798635)
I'm not super experienced with Lua - what's missing for a generic deep copy? Is there no real reflection system?
[ Parent
| on HN ]
Lua has a type of value called "userdata" that is just an opaque reference to a C resource. There's no way for Lua to know how do a deep copy of that resource, if it's possible at all. Tables can also have "metatables" that modify how they function. It's not obvious whether a deep copy should also create a deep copy of the metatable (and its metatable, and so on) or whether the copy should share the original metatable. There's good arguments either way.