[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua voices
- From: Sean Conner <sean@...>
- Date: Wed, 4 Jul 2018 17:25:40 -0400
It was thus said that the Great Laurent FAILLIE once stated:
> Hi,
> I would like to see in Lua :
> 1/ As I discussed several times : Thread safe State sharing. For the
> moment, or you have to "send" bytecode among threads or use a lock
> mechanism which seem to penalize by a large amount performances. I would
> like to have an option at compile time enabling thread safe Lua, having
> out of the box transparent semaphore locking on global objects. Something
> efficient, easy :)
You can recompile Lua with lua_lock() and lua_unlock() defined, but then
you get Python performance because of the "global interpeter lock" you just
introduced.
Second, locking "global objects" isn't enough:
do -- new local scope
local data = {}
spawn_thread(foo,data) -- one system thread using data
spawn_thread(bar,data) -- a second system thread using data
end
You really need the fine grained locking that lua_lock() and lua_unlock()
provide.
Easiest answer---just say to no system threads 8-P
> 2/ yes, I'm missing compactness of C compoundeds operator like += *= :?
> and so on ... something suggested it seems several times on this list but
> seems always disdained by gurus.
Question to answer: is
x += b
the same as
x = x + b
at the metatable level? That is, will (assuming at least one object has a
metatable with the __add() function defined):
x += b
do
mt = getmetatable(x) or getmetatable(b)
x = mt.__add(x,b)
or is this a "different" operator? I only ask becuase Python has
__add__() x = x + b
__iadd__() x += b
But I think the reason that Lua doesn't support this is that it
complicates the grammer or parser.
-spc