Re: alleviate the load of the GC

  • From: Duncan Cross <duncan.cross@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 2 Sep 2015 11:15:59 +0100

On Wed, Sep 2, 2015 at 10:49 AM, Laurent Deniau <Laurent.Deniau@xxxxxxx> wrote:

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.

-Duncan

Other related posts: