On 8/10/2011 7:58 PM, Graham Fawcett wrote:
On Tue, 09 Aug 2011 20:22:40 +0000, dsimcha wrote:
Ok, I've actually managed to come up with a good way to do this without
writing any new low-level concurrency code. The idea is to create two
delegates: nextDel reads the next element into a user-provided buffer.
emptyDel tests whether there's anything left to read.
Doesn't that essentially implement the InputRange protocol, but with
delegates instead of an object?
Not saying it's bad, just wondering what the benefits/tradeoffs of your
delegate-based approach are.
Graham
The fundamental difference between what I've defined and an input range
is that the next() delegate lets you provide your own buffer. Of
course, you can implement input ranges on top of this by defining an
object that manages the buffering, which is exactly what I did.
I could have used objects instead (e.g. a class/struct with a next() and
empty() member function), but as a matter of personal preference I err
on the side of avoiding objects because, when used excessively, they
lead to boilerplate code.