stream == range ?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun May 31 18:52:18 PDT 2015


On 5/31/2015 8:58 AM, Andrei Alexandrescu wrote:
> Given that it seems Design by Introspection has been working well for us and
> we're continuing to enhance its use in Phobos, it seems to me that optional
> methods for ranges are the way to go.
>
> An optional method for any range is
>
> size_t bulkRead(T[] target);
>
> which fills as much as possible from target and returns the number of items copied.
>
> Another good candidate for optional methods is lookahead.

What worked effectively in Warp is:

     E[] lookAhead() { ... }

which, if the range has a bunch of elements E ready to go, this gives it. To the 
consume it,

     void popFrontN(size_t) { ... }


More information about the Digitalmars-d mailing list