Re:What Lua scripting means for Wikimedia and open source
by gngeal on Monday March 18, 2013 @05:25PM
(#5397227)
Why not? Isn't that the whole purpose of coroutines in Lua?
[ Parent
| on HN ]
Re:What Lua scripting means for Wikimedia and open source
by fab13n on Monday March 18, 2013 @06:33PM
(#5397616)
No, quite the contrary: coroutines only yield explicitly, due to a call to coroutine.yield(). They let you control your scheduling deterministically (although multitasking is far from being their only use)
Re:What Lua scripting means for Wikimedia and open source
by gngeal on Tuesday March 19, 2013 @07:35AM
(#5400227)
Note that GP didn't mention the means in which the yielding was to be invoked.
Re:What Lua scripting means for Wikimedia and open source
by ufo on Monday March 18, 2013 @05:32PM
(#5397284)
You can't yield if there is a C function lower down in the stack so I don't think you can always abuse the coroutine system to implement OS threads like that.
Re:What Lua scripting means for Wikimedia and open source
by gngeal on Monday March 18, 2013 @06:23PM
(#5397561)
Are you sure about that? I thought that yields across C functions were added in Lua 5.2. Not to mention that in a controlled environment like the runtime that Wikipedia exposes to you, you can take care of avoiding exposing APIs that would allow people to code themselves into a corner like that (if the C calls are leaves, you're OK even in 5.1).
Re:What Lua scripting means for Wikimedia and open source
by ufo on Monday March 18, 2013 @11:31PM
(#5398743)
You are right that they could use a carefully crafted API to work around the problems. Its also true that yields across C were added in 5.2 but you need to code the C functions in continuation-passing-style using a special API to take advantage of that.