VLERange: a range in between BidirectionalRange and RandomAccessRange

spir denis.spir at gmail.com
Tue Jan 18 04:59:59 PST 2011


On 01/18/2011 06:48 AM, Jonathan M Davis wrote:
> On Monday 17 January 2011 15:13:42 spir wrote:
>> See range bug evoked above. opApply is the only workaround AFAIK.
>> Also, ranges cannot yet provide indexed iteration like
>> 	foreach(i, char ; text) {...}
>
> While it would be nice at times to be able to have an index with foreach when
> using ranges, I would point out that it's trivial to just declare a variable
> which you increment each iteration, so it's easy to get an index even when using
> foreach with ranges. Certainly, I wouldn't consider the lack of index with
> foreach and ranges a good reason to use opApply instead of ranges. There may be
> other reasons which make it worthwhile, but it's so trivial to get an index that
> the loss of range abilities (particularly the ability to use such ranges with
> std.algorithm) dwarfs it in importance.

You are right. I fully agree, in fact. On the other hand, think at 
expectations of users of a library providing iteration on "naturally" 
sequential thingies. The point is that D makes indexed iteration 
available elsewhere.

Denis
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list