[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua on Reddit again
- From: Peter Cawley <lua@...>
- Date: Mon, 31 Jan 2011 14:07:26 +0000
On Mon, Jan 31, 2011 at 1:45 PM, Alexander Gladysh <firstname.lastname@example.org> wrote:
> On Mon, Jan 31, 2011 at 16:26, Peter Cawley <email@example.com> wrote:
>> On Mon, Jan 31, 2011 at 1:10 PM, Steve Litt <firstname.lastname@example.org> wrote:
>>> Speaking about what might replace it -- could something with callback
>>> functions replace it? They're powerful as all getout, but until now appeared
>>> to be the sole territory of toolmakers, with application programmers simply
>>> writing and passing small callbacks. Could that be because in other languages,
>>> callbacks are just too syntactically difficult?
>> node.js has had a lot of publicity recently, and its modus operandi is
>> to have callbacks everywhere as to avoid blocking.
> Side note: You ought to use coroutines in Lua for this.
That was my first thought too, but doing so in the naive way means
that while waiting for a I/O event to complete, you need to remember
the entire coroutine including all of its stack, which is a lot more
expensive than remembering a single closure.