[phobos] Difference between std.range is std.algorithm

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 29 14:58:47 PDT 2011


Is there a simple way to distinguish whether something belongs in std.range or 
std.algorithm? I know that in at least some cases, it's debatable as to 
whether something belongs in one or the other, but is there a general rule 
that we could give in one sentence or so?

For instance, I've been debating the situation with https://github.com/D-
Programming-Language/phobos/pull/147 a bit (it adds takeWhile, drop, and 
dropWhile). drop clearly belongs in std.range, but both takeWhile and 
dropWhile could go in either std.range or std.algorithm. Given the 
similarities in their names to take, takeExactly, and drop, they should 
probably go in std.range. However, there _are_ similar functions in 
std.algorithm (e.g. takeWhile is similar to until). So, I don't know which 
place is better (at present they're in std.range). But I'm not even aware of a 
rule that I could give in a sentence or two which would say what the general 
dividing line between std.range or std.algorithm is. You can get a feel for it 
by seeing what's currently there, but it would be nice if we could have an 
actual rule which made it clearer.

- Jonathan M Davis


More information about the phobos mailing list