lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Now I am reading Diego Nehab's gem on "Filters, Sources, Sinks and Pumps".
To my surprise he does not mention coroutines. I think coroutines with
their "yield" and "resume" are great mechanism to implement filters
and filter chains. They provide an easy and natural way to maintain
filter context while processing chunks of data. Also coroutines all
but eliminate (or rather hide) need for "pumps".
Is there any specific reason they are left out of this gem??

The original implementation actually used coroutines for the
filter chains. Unfortunately, this caused the library to
interfere poorly with pcall(), and some users complained.
The implementation of the smtp.message() function used as an
example the end of the Gem does use coroutines.

As to the relationship between pumps and coroutines, would
you mind clarifying?

Kind regards,
Diego