Should we add drop to Phobos?
Daniel Murphy
yebblies at nospamgmail.com
Tue Aug 16 08:23:18 PDT 2011
"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
news:mailman.2361.1313462679.14074.digitalmars-d at puremagic.com...
>
> They already exist:
>
> dropUntil == find
> dropWhile == !find (i.e. same thing, but the predicate must be negated)
> takeUntil == until
> takeWhile == !until
>
I'd prefer to have all of these available in phobos.
>
> 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.
I think one argument that is often used to argue for more features in the
language applies here - less functions makes for a cleaner phobos, but
messier user code.
eg:
dropWhile!predicate(r) vs find!(Not!predicate)(r)
The second version is noisier, requires extra parentheses, and requires an
import of std.functional whenever it's used.
Won't these end up as simple aliases in phobos?
Disclaimer: I haven't read the github discussion.
More information about the Digitalmars-d
mailing list