Christophe:

> mins and maxs are too specialized to be in phobos IMO.

What are the disadvantage of having them in Phobos?

Regarding the advantages, my experience shows that several algorithms require 
to find all the equally max or min items, it's a common enough pattern. Look at 
the AI book by Norvig to see algorithms that use it.

The problem of not putting this micropattern in Phobos is condemn yourself to 
re-implement it again and again and again every time you need it. And... there 
are bugs and efficiency too to keep in account. This algorithm is simple, but 
it requires to temporarily store all the max/min items found so far. If you 
don't this efficiently, you waste computations and stress the GC. How many 
times do you want to re-implement this, debug it, and tune its efficiency? Once 
is enough.

If you use maxs you are writing bug-free code, short, efficient, and you are 
documenting your code, there is less need to comment your code. And using 
maxs/mins (like using the other higher order functions) allows you to think 
about your code at a higher level.

Bye,
bearophile

Reply via email to