protocol for using InputRanges

Paulo Pinto pjmlp at progtools.org
Thu Mar 27 01:13:27 PDT 2014


On Wednesday, 26 March 2014 at 18:04:44 UTC, Ola Fosheim Grøstad
wrote:
> On Wednesday, 26 March 2014 at 17:36:08 UTC, Andrei 
> Alexandrescu wrote:
>> I think requiring users to call empty before front on input 
>> ranges is a concession we should make.
>
> Then the name should change to "ready". It makes sense to 
> require the user to check that the range is "ready", but not to 
> check that it is "not empty". This will also make more sense 
> for async implementations that will block if "not ready".
>
> IMO the whole interface needs rethinking if you want to 
> gracefully support async data streams where you need to 
> distinguish between: "ready" vs "empty", "front" vs 
> "firstavailable". Both quick-sort, merge-sort, filter and map 
> work well with async data streams.

Why not?

It is how iterators work in most OO languages.

--
Paulo


More information about the Digitalmars-d mailing list