apparently #Roblox uses #Lua coroutines (or I guess Luau coroutines) for #async cooperative #threading: “A task scheduler is what allows coroutines and yielding to work correctly. For example, when you wait(5) in Roblox, the wait function tells the Roblox task scheduler “resume my coroutine in 5 seconds”, and then calls coroutine.yield() to pause the thread until the Roblox task scheduler resumes it.
While the thread is paused, other threads in the game are resumed by the scheduler and run as normal, which is why it is important to yield all the time so that other code in the game gets to execute. In fact, other code (even non-Lua code*) can only run while every Lua thread is yielding, which is why while true do end can crash Roblox! (...) When you call a function like spawn, it places a new coroutine in the task scheduler’s queue rather than resuming it immediately, meaning your function will only start when the scheduler next executes. Internally, this is probably done by putting the newly created coroutine into the queue at time 0, and since the current time is always greater than or equal to 0, it always gets executed the next cycle.” But you’re not allowed to download it unless you have a Roblox account.
"Luau", the #Roblox #Lua dialect, with gradual typing.
on 02021-11-03#Roblox freed their #Luau dialect of #Lua.
on 02021-11-03