Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2004-01-08 12:19:03


 From what I've seen so far, I like your approach very much. Although I
have to admit I haven't looked at it (or anyone else's proposals) very
close. Anyway, the shown example syntax is IMHO as good as it can get in
C++.

Matthias Schabel wrote:
> I don't really know about compile time reduction - a smart compiler
> will undoubtedly use a hash of some sort to reduce names into integers
> or something more manageable... As far as code-writing time goes, I
> guess I spend so much more time thinking about implementation and
> algorithms than actually typing code that the long names are not an
> issue. I also have a personal preference for completely unambiguous
> naming and, in this case, most users won't see this verbose stuff as it
> is more internal to the library. On the other hand, I'm not
> particularly strongly attached to this particular choice of names...

I share your preference for long, unambiguous names. And a decent
editor/IDE should have some support for them (e.g. (x)emacs'
dabbrev-expand). Also, my experience tells me that the correctness of
the program and catching stupid programmer errors is ways more important
than the compile time.

> This snippet is carrying some baggage from an earlier version which was
> not specifically tied to the SI model; i.e. it was written to deal with
> arbitrary unit systems. A more concise version with the existing
> library would be :
>
> template<class Y>
> typename SI<Y>::quantity
> idealGasLaw(typename SI<Y>::pressure P,
> typename SI<Y>::volume V,
> typename SI<Y>::temperature T)
> {
> return (P*V/(8.314*(_joules/(_kelvin*_mole))*T));
> }

This looks very nice so far, but I have one question: Why is <Y>
attached to SI instead of:

template<class Y>
typename SI::quantity<Y>
idealGasLaw(typename SI::pressure<Y> P,
             typename SI::volume<Y> V,
             typename SI::temperature<Y> T)
{
     return (P*V/(8.314*(_joules/(_kelvin*_mole))*T));
}

as it is AFAICS not part of the SI-model to define the number-type. Or
was this just a typo?

Another question: Have you looked at my constant library? I think it
could make a good companion of your library, reducing the above to

     return P * V / ( boost::chemistry::G * T );

with a properly defined boost::chemistry::G and now being truly generic
as it would even works for types Y than don't mix with doubles. If you
are interested in exploring this or have questions about the constant
library, drop me a private mail.

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial solutions & technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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