[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: metamethods for assignment and type conversion
- From: "Aaron Brown" <arundelo@...>
- Date: Thu, 09 Aug 2007 00:32:07 -0400
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.