C++Now! 2012 slides
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jun 7 18:26:13 PDT 2012
On Friday, June 08, 2012 00:30:06 Dmitry Olshansky wrote:
> On 07.06.2012 22:34, Peter Alexander wrote:
> > Don't get me started on std.algorithm.find...
>
> Why not ? It's perfect example of goodness of generic programing,
> flexibility (for free) + speciality (when you need) for the win.
> If you language lacks such construct you end up inveting ways around it:
> - make findInt, findString, quickFindString, findPerson etc. * number of
> containters
> - shoehorn everything into a simpler design: qsort, boxing-unboxing etc.
std.algorithm does a lot of really cool stuff in a very generic way, and on the
whole, it works very well. It's true that its functions tend to be more
complicated than most, but they're generally not complicated to use, and if
you're going to have that kind of complication, it's best to have it in the
standard library written by experts in the language rather than trying to
write it yourself. And D manages to make such functions _very_ sane in
comparison to what C++ would need to do to get the same result. If anything,
the problem here is simply that not all of these functions are tested as well
as they should be (as the bug with min shows).
Personally, my favorite function in std.algorithm is startsWith (or endsWith).
It just about blew my mind when I realized what it was doing. It is
fantastically cool how it uses recursive templates to get its job done, and it
makes for an incredibly powerful and easy to use function.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list