Re: alleviate the load of the GC

  • From: Laurent Deniau <Laurent.Deniau@xxxxxxx>
  • To: "<luajit@xxxxxxxxxxxxx>" <luajit@xxxxxxxxxxxxx>
  • Date: Wed, 2 Sep 2015 11:52:15 +0000

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>
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,

In most languages, expressions and statements are not the same and fill
different purposes, including C/C++.

where many statements are just containers for a expression,

This is not correct. You could somehow say compound statement are "containers"
for statements. Anyway, in C/C++, statements can contain expressions and
expressions can contain statement but not compound statement (except with gcc
extensions).

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.

Right, but for example in Lua

local a, b = b, a

should be overloaded has

local a, b = __assign(nil, a), __assign(nil,b)

same for tables (and hence globals). I don't real problem with the special
semantic of Lua. But I see tremendous applications ;-)

Best,
Laurent.


Other related posts: