RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 8 17:47:55 PDT 2008


Manfred_Nowak wrote:
> Andrei Alexandrescu wrote:
> 
>>  feedback would be highly appreciated
> 
> 1) Example in "4. Bidirectional range"
> 
> Reversing of ranges can be done in constant runtime, but the example 
> exposes runtime linear in the number of elements.
> 
> This might be a hint, that a "6. Reversable Range" might be required, 
> because a range reversable in constant time requires more space.

There are numerous collections and ranges to be defined, of course. The 
five-kinds taxonomy is time-tested and allows implementation of a great 
many algorithms. Beyond that, users can define many containers and 
ranges with additional operations or with improved properties of 
existing operations.

> 2) [left,right][Diff,Union]
> 
> Ranges are not sets; therefore not only me might have problems to 
> capture the idea behind "difference" and "union" on ranges.

I am opened to better names. Bartosz talked me into the ones above. I 
used these:

leftToLeft
leftToRight
rightToRight

> Of course one can define whatever one wants, but I would prefer
> [sub,snip,cut,split,...][B,E][B,E] (r,s)
> 
> I.e. `subBB(r,s)' is the subrange of `r' starting at the beginning of 
> `r' and ending at the beginning of `s' (including the beginning of `r', 
> but not including the beginning of `s').
> 
> It my be of some worth to include the `B' or `E' as parameters to the  
> choosen keyword(?) to enable algorithmically accesses:
> 
> | sub(B,B,r,s)
> 
> instead of `leftDiff( r, s)'

I find these too cryptic, but to each their own. I predict that 
primitive names will become a bicycle shed. In the end we'll have to use 
enum :o).


Andrei



More information about the Digitalmars-d-announce mailing list