From: Dan W. (danw_at_[hidden])
Date: 2004-01-07 05:24:47
David B. Held wrote:
> 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
> Speed s = 2 * met / sec;
I'd go for
s = 2 m/s; //if at all possible, and would try really hard
Re.: Name collisions: I don't give a damn; the compiler'll catch'em.
In any case, we're talking application of the library, not the library
itself, when we speak of what names to use for what.
Now, would there be any way on Earth or Mars to enable a syntax like
above? --i.e. no * at all. I know there's no blank-space operator that
we can overload .. :) ..
How about starting lines using units with a $ sign...
$ s = 2 m/s;
#define $ spirit_of_units()=
which spirit_of_units is a class that triggers parsing by spirit
(Must be the fact that it's 5:25 am and haven't slept yet..)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk