Should we add drop to Phobos?

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 15 19:44:29 PDT 2011


On Tuesday, August 16, 2011 04:37:18 Andrej Mitrovic wrote:
> Also dropWhile and dropUntil should probably be added too.

They already exist:

dropUntil == find
dropWhile == !find (i.e. same thing, but the predicate must be negated)
takeUntil == until
takeWhile == !until

There may be a chance of talking Andrei into renaming until takeUntil, but 
that's as far as you're going to get with that - if you'll even get that far. 
There was already quite a bit of discussion over it in a previous pull 
request:

https://github.com/D-Programming-Language/phobos/pull/147

Andrei is against adding functions which are functionally identical to 
existing functions save for the negation of the predicate, and he's definitely 
against adding aliases. To some extent, I'd like to have functions which are 
functionally identical save for the negation of the predicate, because I think 
that it makes for clearer, neater code, but I think that he has a very good 
point in that we don't want to clutter Phobos with functions which are nearly 
identical. New functions must add something of definite value to be worth 
adding.

As it is, Andrei doesn't like the idea of drop and wanted me to bring it up 
for discussion in the newsgroup. So, at this point, we'll be lucky to get 
drop. But nothing in Phobos will do what drop does, whereas dropUntil, 
dropWhile, takeUntil, and takeWhile all either already exist under other names 
or functions exist which are the same save for the negation of the predicate. 
So, there's at least a chance of adding drop.

- Jonathan M Davis


More information about the Digitalmars-d mailing list