Feedback on Streams concept, similar to Ranges
monkyyy
crazymonkyyy at gmail.com
Wed May 17 14:53:04 UTC 2023
On Wednesday, 17 May 2023 at 14:40:48 UTC, Andrew wrote:
> 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.
What does duck typing have to do with nogc?
If you said `writeToStream(T)(T items)` and assumed the user
would provide a T that defined opSlice, opIndex and a length why
couldnt whatever systems have nogc somewhere in the pipeline that
makes it werk
More information about the Digitalmars-d
mailing list