"Steven Schveighoffer" , dans le message (digitalmars.D:144156), a
 écrit :
>> Where could I see an
>> implementation of a delegate suitable for readUntil ?
> 
> In the source code for the revamped stdio.  Here is a byChunk range which  
> uses it:

I see. Are you not concerned by the fact that with this API, the input 
stream has to perform heap allocation when its internal buffer is full 
because the delegate could always ask for some more characters. That 
prevents the possibility to make a reading mecanisme that does not 
allocate anything on the stack.

>> One last point: any comments about using writeTo with my "stream" API
>> like readFrom ?
> 
> I think this is what writeTo (as proposed) already does.

the proposed writeTo is:
writeTo(void delegate(const(char)[]) sink, in char[] format).
Here, the writeTo method writes the character in its own buffer, then 
gives it to sink.

A writeTo with a "stream API" would be:
writeTo(char[] delegate(size_t) stream, in char[] format).
Here stream provides a buffer, and writeTo has to use this buffer, then 
tell how much buffer it used to stream.

I'm not sure mine is better, I'm just asking.

-- 
Christophe

Reply via email to