lua-users home
lua-l archive

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


"Copying a Lua value" has no consensual definition: each use-case has its own views on the handling of circular and shared references, upvalues, references to environment entities such as global vars, etc. Of course, the notion of "copying a userdata" is also completely dependent on the kind of C value embedded in that userdata.

For instance, if I copy a table which has a metatable, should I carry along a structural copy of the metatable, or retrieve it in the destination environment? How do I maintain the correspondence between representations of the same object in different Lua states ? What if it doesn't exist in the destination? What if it references C functions, as is often the case?

Pluto offers extreme configurability, allowing you to pretty much define what you mean by "copying". As a result, it's complicated to use. If you have a clear, precise, reasonably simple and stable view of what it means for you to copy a Lua value, and you don't want to express it through Pluto, you should probably write your own {de,}serializer. My advice would be to try very hard not to over-engineer something fancier than what you actually need. If reusability/generality is important for you, use Pluto.