Documentation and stuff forthcoming. Gist contains another example showing how callback arguments are handled. Looking for feedback; if you can think of a way to make this neater or think there are features missing let me know.
The wait function will return anything passed into the callback generated by continue. If continue is called more than once before a call to wait, only the first of those generated callbacks to be invoked will cause execution to continue.
Although I think next is the standard name for the callback function continue usually means something else in programming languages
(also next is shorter)
farzher wrote:Not a bad idea node.js is my main language
Although I think next is the standard name for the callback function continue usually means something else in programming languages
(also next is shorter)
I considered 'next' but it's a global in Lua. Of course you can name it whatever you like since it's just a parameter to a user defined function; neither solution here exposes any fixed identifiers. I sort of like "go" or "callback" too.
time thief wrote:I considered 'next' but it's a global in Lua. Of course you can name it whatever you like since it's just a parameter to a user defined function; neither solution here exposes any fixed identifiers. I sort of like "go" or "callback" too.
I didn't realize `next` was a thing
While looking that up I also noticed lua has `goto`
They made some weird decisions on features. We don't get the basic continue, yet we get the dangerous goto
That's interesting though. Maybe I should refactor some loops to use `goto continue` instead of nesting if statements (slightly off topic, but we are talking about nesting)
farzher wrote:While looking that up I also noticed lua has `goto`. They made some weird decisions on features. We don't get the basic continue, yet we get the dangerous goto.
Personally I don't think that's weird or dangerous. Continue can be implemented in terms of goto. But the reverse isn't possible.