Feedback on Streams concept, similar to Ranges

Andrew andrewlalisofficial at gmail.com
Wed May 17 14:40:48 UTC 2023


On Wednesday, 17 May 2023 at 13:47:15 UTC, Monkyyy wrote:
> For ranges I could use `takeExactly` and store the range 
> somewhere to have the frame syncing enforcment; that sort of 
> thing comes from just duck typing templates so you can build up 
> your concept.
> By having your primitive be [] rather then a list of functions 
> to match, airnt you reducing the expressiveness if actaully 
> adopted with a liberty of algorthims?

Yes, I am reducing the expressiveness, but I think it's a good 
idea. Ranges aren't @nogc/betterC compatible, and they don't 
support giving extra context about how many items were written or 
read in a consistent way. Streams are also defining their 
primitive as anything implementing `int readFromStream(T[] 
items)` or `int writeToStream(T[] items)`, or both.

I know it's mostly a matter of personal preference, but I think 
there is value in having the standard library use a restrictive 
interface, instead of duck-typing, since it'll (hopefully) be 
used all over the place.


More information about the Digitalmars-d mailing list