finish function for output ranges

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sun Aug 12 17:08:02 PDT 2012


On 12/08/12 00:29, Andrei Alexandrescu wrote:
> I think we should reify the notion of finish() as an optional method for output
> ranges. We define in std.range a free finish(r) function that does nothing if r
> does not define a finish() method, and invokes the method if r does define it.
>
> Then people can call r.finish() for all output ranges no problem.

What about a start() method?  You may recall in the RandomSample revisions I had 
to introduce a tweak to ensure that the first value returned by front() was set 
only the first time front() was called, and not in the constructor.

The idea of the start() method would be to addresses this requirement, i.e. to 
do something immediately before front() gets called for the first time and not 
earlier.


More information about the Digitalmars-d mailing list