lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> And getting performance out of immutable data requires very clever
> optimizations.

It seems to be brake intially, but one the other hand it opens up a
large amount of optimizations, and that is what I'm aiming at. It
makes coding complex programms easier, if you have to worry less about
structures changing as some side-effect to what you are doing, while
you are looping through them.

Also the prototyping mechanism in Lua and in Javascript makes it cheap
to create a new table that is an extension to an existing table.

Say for example, one optimization is this variable caching we do
manually can be automated
local a = b.c.d.e.f.g.h;
for ... :
 a.do()
 -or-
 b.c.d.e.f.g.h.do(),
end
Once you know b.c.d.e.f.g and h are immutable, you can write this
directly into the loop, and the compiler would only have to check if b
changed, to know h is still the same.

Also I suppose the hash/array-tables could be arranged more
compact/efficient if it would be assured they wouldn't change.

And yes this makes multithreading easy. you only need to atomize
access to globals. However, thats not what I'm aiming at, it has IMHO
value enough even without.