protocol for using InputRanges

monarch_dodra monarchdodra at gmail.com
Thu Mar 27 09:02:16 PDT 2014


On Thursday, 27 March 2014 at 15:19:37 UTC, Andrei Alexandrescu 
wrote:
> On 3/27/14, 3:49 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>> I was originally going to do that, but then I took a closer 
>> look at the
>> documentation, which says ([1] in the documentation of 
>> `isInputRange()`):
>>
>> "Calling r.front is allowed only if calling r.empty has, or 
>> would have,
>> returned false."
>
> Probably we need to amend that. For efficient ranges, front() 
> and popFront() should only be guaranteed to work if either 
> empty() or length() were evaluated first, and they returned 
> false or nonzero, respectively.

I just want to point out that I think allowing empty to have an 
*observable* side effect will have cataclysmic repercussion in 
validating a release build, what with all our "assert(!empty);" 
calls and all.


More information about the Digitalmars-d mailing list