Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-10-29 14:52:19

----- Original Message -----
From: "Stewart, Robert" <stewart_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, October 29, 2001 10:53 AM
Subject: RE: [boost] Math constants - naming convention?

> PI_1_2
> PI_1_4
> PI_1_3
> PI_2_3
> PI_2

<Responding to the whole thread, not this particular post> In general, I
consider it a mistake to include small integers in an identifier name,
whether as digits or spelled out. It places a greater burden on the library
user (because they have to remember that 'PI_1_2' exists but
'PI_156785_786971290' doesn't) and on the library implementor (because they
have to make sure all of the various versions of 'PI * A / B' exist. My
first preference for spelling 'PI * A / B' would be 'PI * A / B'. However,
if this leads to unacceptable performance, how about 'pi_fraction<A,
B>::value' (or some variant thereof)? The template class 'pi_fraction'
could be specialized for common values of 'A' and 'B', but would still for
less common values of 'A' and 'B'.

> > log_pi // cos () not allowed in name

The same principle applies. If constants in the form 'log(A)' are common,
how about this:

namespace boost { namespace math { namespace constants {

  template<class Constant> log {
    static double const value = std::log(Constant::value);
  template<> class log<pi_fraction<1, 1> > {
    static double const value = /* insert digits here */;


Rainer Deyke (root_at_[hidden])
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at, gregod at, cpdaniel at, john at