On Sep 2, 2015, at 12:15 PM, Duncan Cross <duncan.cross@xxxxxxxxx> wrote:
On Wed, Sep 2, 2015 at 10:49 AM, Laurent Deniau <Laurent.Deniau@xxxxxxx>
Overloading other operators (beyond syntactic sugar) leads to some
optimisation like sharing temporaries, building lazy expressions, or flatten
expressions that alleviate a lot the GC. C++ libraries are using these kind
of optimisations for decades now with success. To be a bit provocative,
overloading operators has little sense without being able to overload '=',
except basic syntactic sugar. The operator '=' should be seen as a component
of the expression (or statement), and not as a special case, and there is no
reason to not be able to overload it.
One thing to note: in the Lua language, there is a strict separation
of expression and statement. Unlike in C/C++ and many other languages,
where many statements are just containers for a expression,
Lua's "a =
b" is simply not an expression the way that "a + b" is. This is why,
for example "a = b = c = 1;" just works in C but not in Lua.