stream == range ? [Sliding window]

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun May 31 15:54:05 PDT 2015


On 5/31/15 2:34 PM, Dmitry Olshansky wrote:
> On 01-Jun-2015 00:13, Andrei Alexandrescu wrote:
>> On 5/31/15 10:50 AM, Dmitry Olshansky wrote:
>>> 1. There must be a way to look at underlying buffer w/o copying
>>> anything.
>>
>> bulkRead would be useful for unbuffered streams. The input range
>> interface requires a 1-element (at least) buffer. Buffered ranges would
>> indeed need more optional primitives. -- Andrei
>
> Then if unbuffered stream is an InputRange and it would by "default"
> fallback to reading one byte (T.sizeof but anyhow) at a time .. sounds
> scary. Might be cute but never what we'd want.

There's some misunderstanding along the way. Input ranges use buffering 
internally as a matter of course, nothing scary about that. In addition 
to that, primitives that transfer data in bulk are welcome too. That's 
how many languages define their file APIs. Zero-copy interfaces and such 
are of course welcome as well. -- Andrei



More information about the Digitalmars-d mailing list