|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2004-01-07 04:37:20
"Daniel Frey" <daniel.frey_at_[hidden]> wrote in message
news:btgghe$7rh$1_at_sea.gmane.org...
> > Speed s = 2 m / s;
>
> This is one of the pitfalls! I haven't found a solution, but I'd like to
> point out that it is a problem which needs to be addressed. Units
> often have very brief identifiers which than clash too easily with
> the variables one usually uses. And you don't want to write
>
> unit::Speed s = 2 * unit::m / unit::s;
>
> all the time, do you?
I would do two things. 1) put all the units in their own namespace,
so people can fully qualify them if need be. 2) spell out the units,
using abbreviations where necessary to make them conveniently
short. Also, I know the precedence is wrong, but it would be
really nice to overload operator^(), IMO. So using your example:
using namespace unit;
Speed s = 2 * meters / seconds;
Maybe all the names could have abbreviations to make it even
shorter?
Speed s = 2 * met / sec;
Some units have easy abbreviations, and others are not so easy.
Dave
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk