lua-users home
lua-l archive

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

Lua wrote:
*Adrien de Croy < <>> writes:
*In which case, separate functions will need to be written to deep-copy
objects... you end up with code like

deepcopy(var1, var2);

or maybe


instead of

var1 = var2;

My thought after reading this thread was:

var1 = var2:Duplicate(); or
var1 = var2:Copy()

neither of these affect the C++ object that is wrapped by var1, var1 instead gets a new pointer to wrap (being a copy), and the old one is garbage-collected.

If you want to modify the pointer that var1 wraps, then var1 needs to be involved in the function that does the assignment.



I do this in some of my Lua code and it works pretty well. I find it makes it pretty easy to tell when a new resource is allocated vs. simply referenced in a new way.

Of course what's clear to me, may be mud to others...


Adrien de Croy - WinGate Proxy Server -