lua-users home
lua-l archive

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





On Tue, Jan 14, 2014 at 8:58 AM, Fabien <fleutot+lua@gmail.com> wrote:
"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.


Yes. This is true and I did not mean to convey otherwise. It is also why i'm interested in more low level "mechanisms", as opposed to high-level solutions.
 
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.

Sage advice and much appreciated. I'll have a look at Pluto, as well.

-Andrew