lua-users home
lua-l archive

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

Adrien de Croy wrote:

this would also then allow lua script like

function dosomething(object1, object2)
   object2.somemember = "hello";
   object1 = object2; -- deep copy in host via __assign
                      -- metamethod rather than table reference

I think this is a bad idea, because it's a radical change to
Lua's semantics, in which an assignment whose left-hand side
is a variable name always mutates the variable, never the
value contained in it.  An __assign metamethod would change
that and also block regular assignment.

Better to do something like:

 deepcopy(src, dest) -- Mutates dest into a deep copy of src.


A new home for Mom, no cleanup required. All starts here.