06-Feb-2014 22:29, Andrei Alexandrescu пишет:
On 2/6/14, 10:15 AM, H. S. Teoh wrote:
That's only because the current output range API consists of only a
single .put method. Please see the other thread started by Adam Ruppe:
we should spend some time to think about how we can streamline output
ranges so that they can be used just as easily as input ranges --
y'know, with UFCS chaining and such, that doesn't require a ton of
boilerplate like the current process of: declare output range, pass to
function, get data from result, pass to next function, etc.. This is
primarily a syntactical problem, not a logical one, and since we're so
good at syntactic bikeshedding, we should be able to solve this
relatively easily, right? ;-)
I don't think it's that easy. For example the output range must be
passed as a ref parameter into the function, which is already
introducing friction.
FWIW things we can add are to output ranges:
~= for convenience
.flush() or .done() to mark the end of several writes
.clear() to clear the range (useful if e.g. it's implemented as a slice
with appending)
.reserve(n) to notify underlying sink that it n items are coming (it
should preallocate etc.)
--
Dmitry Olshansky