protocol for using InputRanges

Walter Bright newshound2 at digitalmars.com
Thu Mar 27 14:28:05 PDT 2014


On 3/27/2014 1:59 PM, Steven Schveighoffer wrote:
> On Thu, 27 Mar 2014 16:53:35 -0400, Walter Bright <newshound2 at digitalmars.com>
> wrote:
>
>> On 3/27/2014 9:12 AM, monarch_dodra wrote:
>>> If you initialized the next element in both constructor
>>
>> As mentioned earlier, requiring this of a range constructor makes it
>> impossible to separate composition of a range with using it.
>
> Not impossible. Use lazy initialization.

That still doesn't work, because then you could be calling front, and front 
might fail if there's no input.

What is wrong with following the protocol? Why must we introduce all these 
caveats for ranges, like streams not working, front that can fail, can't do C# 
style LINQ, etc.? For what gain?


> It only makes sense if you are using empty in your processing of the range.

I.e. follow the danged protocol and it works.



More information about the Digitalmars-d mailing list