
Boost : 
From: David Richardson (dgr24_at_[hidden])
Date: 20031016 08:08:36
Paul A. Bristow wrote:
> 
>  The slides have examples where the units are from physics. So you
>  represent a number's units as a ntuple of exponents with each
>  exponent corresponding to one of the fundamental SI units.
>  Arithmetic operations on numbers with these units have well
>  defined rules to compute the resulting units.
> 
>  If the semantics of the exponents in the ntuple are user defined, ...
> <snipped>
>
> Would an example here be if the exponents in the ntuple were of type rational
> rather than type integer?
> Could this meet the need for fractional dimensions?
> (At the cost of making it even more complicated! Especially to ensure it doesn't
> have a runtime cost).
The library has to make some choice about the internal way it
represents the exponents, and the users just have to follow
whatever convention the library has.
The concern is if a user stuffs dimensions into the ntuple that
do not have the same semantics the library expects (e.g.
multiplication of two numbers does not result in the exponents in
their ntuples being added). If the library is hard coded to do
conversion as if the ntuple contained physical dimensions, the
library may incorrectly compute types for arithmetic expressions.
But allowing the user to specify both the contents of the ntuple
and the conversion rule seems to make implementation harder, and
it isn't clear (at least to me) how many problem domains/users
would benefit from this flexibility.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk