Boost logo

Boost :

From: Paul A Bristow (boost_at_[hidden])
Date: 2003-06-17 11:54:30


| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Daniel Frey
| Sent: 17 June 2003 11:19
| To: boost_at_[hidden]
| Subject: [boost] Re: Math Constants Formal Review - ()s are
| > 1 Control of precision is essential,
| > and some users wanted to be able to use
| > float, double and long double at the same time.
| "at the same time" is exactly what the "separate headers approach"
| doesn't provide if you can only include one at a time IIUC.

Absolutely, but on the previous review,
many users wanted to "Keep It Simple Sir"
and deliberately only have (for example) double const pi -
avoiding the complexity of other schemes, get warnings of conversions,
difficulty during debugging,
and inefficient code from older compilers.
They would chose just the plain double const files.
You would just ignore them - at no cost to you!
  
| > 2 Avoiding paying for what you don't use, which leads to
| Hm, there is some small overhead, but not much IMHO. In fact
| far less than a lot of other boost libraries. :)

Agreed, though don't forget there are dozens of constants, not just pi.
 
| > 2a MACROS provide a simple way of avoiding some cost for
| > constants you don't use, (Although some Boosters were opposed
| > to MACROs because they pollute the global namespace).
|
| I'd like to backup the latter.
| With MACROs, you cannot add a 'using
| namespace boost::math;' and use a plain 'pi' instead of 'BOOST_PI'.
| Using MACROs is a pain and should be avoided if possible.

Agreed but ...
Some users wanted to "Keep It Really Simple Sirs" and for them the
MACROS
files are available. For systems where every byte counts, they may be
best.
(For me, while generating the other files,
the extra cost of generating the MACROS file is negligible).
If you hate MACROs them don't use these files - at no cost to you!

| But this is exactly what my code tries to do. You write
| 'pi', and when
| using it, all calcalations are forwarded to use the value
| returned from
| a function (actually pi_value<T>::operator()). Some magic is
| provided
| for convenience like in the example above and you can select
| the type
| explicitly be using a static_cast. AFAICS you get all what you are
| asking for...

I will try to compare your proposal more carefully with Michael
Kenniston's
version - which seems to work efficiently and conveniently and
extensibly
with small enough risk of surprises about precision for novice users.
As Ed Brey reported during this review, Kenniston's method files
DO generate efficent code with Optimising MSVC 7.1 and gcc,
not creating any code for unused constants - an important requirement.
So the only cost is in compile time - which should be tolerable.

However I am away from my machine at present so it may be a day or two.
If you have more examples of use similar to those in the folder
"testFunctionConstants",
containing a test.cpp with lots of comments and header
functionconstants.hpp
these will be helpful. the Folder pi also gives his examples of
extending to
handle complex. quadfloat folder gives an example of a UDT
(a 128bit floating point software type).

I am confident that your system also generates efficient code using an
efficient compiler.
But have you considered or tried debugging?

Paul


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk