core.traits?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 9 19:25:35 UTC 2019


On Wed, Jan 09, 2019 at 06:55:30PM +0000, jmh530 via Digitalmars-d wrote:
[...]
> One thing I like about libmir's sum function
> http://docs.algorithm.dlang.io/latest/mir_math_sum.html
> was that the algorithm you use to return the sum can be chosen with an
> enum on the template. So it's really a collection of different sum
> algorithms all in one. Set the default as something reasonable and
> then let the user decide if they want something else.

That's an excellent idea.  Have a generic default algorithm that
performs reasonably well in typical use cases, but also give the user
the power to choose a different algorithm if he knows that it would work
better with his particular use case.

Empowering the user -- over time I've come to learn that this is always
the best approach to API design.  It's one that has the best chance of
standing the test of time.  Fancy APIs that don't pay enough attention
to this principle tend to eventually fade into obscurity.


T

-- 
I am Ohm of Borg. Resistance is voltage over current.


More information about the Digitalmars-d mailing list