Another new io library

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 18 12:20:58 PST 2016


On 2/18/16 2:53 PM, Wyatt wrote:
> On Thursday, 18 February 2016 at 18:35:40 UTC, Steven Schveighoffer wrote:

>> But the concept of what constitutes an "item" in a stream may not be
>> the "element type". That's what I'm getting at.
>>
> Hmm, I guess I'm not seeing it.  Like, what even is an "item" in a
> stream?  It sort of precludes that by definition, which is why we have
> to give it a type manually.  What benefit is there to giving the buffer
> type separately from the window that gives you a typed slice into it? (I
> like that, btw.)

An "item" in a stream may be a line of text, it may be a packet of data, 
it may actually be a byte. But the compiler requires we type the buffer 
as something rigid that it can work with.

The elements of the stream are the basic fixed-sized units we use (the 
array element type). The items are less concrete.

>> And I think parsing/processing stream data works better by examining
>> the buffer than shoehorning range functions in there.
>>
> I think it's debatable.  But part of stream semantics is being able to
> use it like a stream, and my BER toy was in that vein. Sorry again, this
> is probably not the place for it unless you try to replace the
> std.stream for real.

I think stream semantics are what you should use. I haven't used 
std.stream, so I don't know what the API looks like.

I assumed as! was something that returns a range of that type. Maybe I'm 
wrong?

-Steve


More information about the Digitalmars-d mailing list