stream interfaces - with ranges
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri May 18 08:15:58 PDT 2012
On 5/18/12 2:52 AM, Mehrdad wrote:
> On Thursday, 17 May 2012 at 14:02:09 UTC, Steven Schveighoffer wrote:
>> 2. I realized, buffering input stream of type T is actually an input
>> range of type T[].
>
> The trouble is, why a slice? Why not an std.array.Array? Why not some
> other data source?
> (Check/egg problem....)
Because T[] is the fundamental representation of a typed contiguous area
of storage.
> Say you're tokenizing some input range, and it happens to just be a
> huge, gigantic string.
>
> It *should* be possible to turn it into tokens with slices referring to
> the ORIGINAL string, which is VERY efficient because it doesn't require
> *any* heap allocations whatsoever. (You just tokenize with opApply() as
> you go, without every requiring a heap allocation...)
>
> However, this is *only* possible if you don't use the concept of an
> input range!
But e.g. splitter() does exactly as you say. It's a range and does not
use memory allocation.
Andrei
More information about the Digitalmars-d
mailing list