Revised RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 12 10:47:54 PDT 2008


Ary Borenszweig wrote:
> Andrei Alexandrescu wrote:
>> In wake of the many excellent comments and suggestions made here, I 
>> made one more pass through the draft proposal for ranges.
>>
>> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html
>>
>> There are some comments in red illustrating some uncertainties (not 
>> all), and the names of the primitives have been updated. Bicycle shed 
>> galore! But don't forget to comment on the reactor as well :o).
>>
>>
>> Andrei
> 
> Two questions:
> - Is it possible to add elements to a range? Suppose a linked list, you 
> want to traverse it's elements until a condition is met on an element, 
> and then add something after it. Or before it. I see there's "put", but 
> it also says "An output range models a one-pass forward writing 
> iteration.", so I think it's not the same.

Never. Ranges never grow. You need access to the "mother" container, 
which will offer primitives for insertion and removal of elements.

> - The same question applies if you want to delete an element from a range.

Same.

> As for the names, I think it's impossible to find one-word names for the 
> concepts you want to express. I always prefer expressive, easy to 
> remember names instead of shorter but less meaningful names. Maybe:
> 
> head --> first
> toe --> last
> next --> moveFirst / dropFirst / skipFirst
> retreat -> moveLast / dropLast / skipLast
> done --> isEmpty (it's strange to think of a range as done)
> 
> So it's like dropFirst / dropLast shrink the range from either end, 
> until it's empty.
> 
> Sorry if these things were already discussed, I didn't have time to read 
> the hundreds of posts of the previous discussion, just some and the next 
> proposal.

Yeah it's getting crazy.


Andrei


More information about the Digitalmars-d-announce mailing list