|
Boost : |
From: Matt Austern (austern_at_[hidden])
Date: 2001-05-14 13:02:00
Ed Brey wrote:
> A general point I'd like to raise deals with providing of derived
> values, like pi/2. Anything like this that the user could easily do
> himself rubs me as bad interface design. There will always some
> constants missed that some users want and many constants included that
> most users never use. The interface will be neither minimal nor
> complete. By including just fundamental constants, it will be minimal,
> and it will always be complete, because its mission will be more
> narrowly scoped to just being a building block for the user. (The only
> exception to this are common terms that cannot be computed at compile
> time, like sqrt(2). Here, I see no choice but to go for the "what tends
> to be useful" heuristic.)
I have mixed feelings about constants like "one" and "zero". It seems
to me that they are genuinely useful, but that they serve a different
purpose from the other constants.
Most of these constants are irrational (mostly transcendental) numbers
that users can't easily compute for themselves. That's useful. "One"
and "zero" are things that users can easily compute for themselves;
they just write 1 or 0. They're useful, but for an entirely different
reason: they're a property of each numeric type, and they're useful for
generic programming.
I'm not convinced that 1 and 0 belong in a numeric constants class; they
seem more like things that belong in a numeric type traits class, or maybe
even something that's still more general. There are plenty of types for
which you can reasonably ask for the additive or multiplicative identity
element, but where these transcendental constants make no sense. (Integers,
NxN matrices, quaternions,... There's a sensible "zero" even for strings.)
--Matt
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk