On Oct 30, 2014 9:47 PM, "Graham Wakefield" <[email protected]> wrote:
>
>
> On Oct 31, 2014, at 11:22 AM, Tim Caswell <[email protected]> wrote:
>
> > I think that callback support can easily be integrated into the
existing callback APIs.  Here is an example of an API that supports both
blocking and non-blocking syntax.  If you leave out the callback and are in
a coroutine, it will suspend the coroutine while blocking on the I/O.  The
internal code can still do things in parallel with callbacks, but the
external API is nice and sync.
> >
> >
https://github.com/luvit/luvit/blob/c83252fcf2b085fb9c272425b008a829fe6879ec/test-tls.lua#L276-L299
>
> Here's a fan of the coroutine-based sync style (of course).
>
> > Integration with a callback API simply requires a new line at the top
at the bottom and callback internally replaced with `next`.
> >
> >
https://github.com/luvit/luvit/blob/c83252fcf2b085fb9c272425b008a829fe6879ec/test-tls.lua#L50-L71
>
> Shouldn’t onAddress and onConnect be local?
> Also since “next” is a built-in function in Lua, it might be better to
use a different name to avoid the possibility of hard-to-understand bugs in
the future.
>
They are local.  But since I like to write them in the order they happen,
the declarations have to be at top.   I'm using luacheck in my editor to
help with scoping bugs.  Its saved me so many issues and made refactoring
less painful.

You're right that I probably shouldn't clobber builtins.  Maybe I'll just
replace the callback art since the original can't be used anyway to support
coroutine mode.

> --
> You received this message because you are subscribed to the Google Groups
"luvit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to