3 ms·
>I was surprised that you couldn't easily copy a table Lua's designers have a sort of maxim "if it can't be done perfectly, let the user roll their own". This
by scythe 4y ago
>I was surprised that you couldn't easily copy a table
Lua's designers have a sort of maxim "if it can't be done perfectly, let the user roll their own". This can be frustrating, but for table-copying it's not surprising. Do you copy subtables by reference or value? What about recursive tables? Mutually recursive subtables? Closures in tables? And then userdata can contain references that are opaque to the language runtime. It's not easy to define the behavior of deep copy in the fully general case.