Ranges, constantly frustrating

Regan Heath regan at netmail.co.nz
Wed Feb 12 02:44:57 PST 2014


On Tue, 11 Feb 2014 13:11:54 -0000, Tobias Pankrath <tobias at pankrath.net>  
wrote:

> On Tuesday, 11 February 2014 at 13:00:19 UTC, Regan Heath wrote:
>> import std.stdio;
>>
>> struct S1 {
>>    private int[] elements = [9,8,7];
>>    int opApply (int delegate (ref uint, ref int) block) {
>>        foreach (uint i, int n ; this.elements)
>>            block(i, n);
>>        return 0;
>>    }
>> }
>>
>> void main()
>> {
>> 	S1 range;	
>> 	foreach(uint i, int x; range)
>> 	{
>> 	  writefln("%d is %d", i, x);
>> 	}
>> }
>>
>> R
>
> byLine does not use opApply
> https://github.com/D-Programming-Language/phobos/blob/master/std/stdio.d#L1389

Ahh.. so this is a limitation of the range interface.  Any plans to "fix"  
this?

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list