Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-10-15 15:01:49


At 11:27 AM 10/15/2003, David Richardson wrote:

>Were cases other then addition considered?

Yes. I just used addition as an example.

> It seems like this
>would not work for multiplication unless the user was also allowed
>to specify a rule of the resulting unit of a multiplication of a
>user tagged variable.

There isn't any doubt that user-defined units raise all sorts of questions.
The point of the posting was to raise the issue. I don't have solutions.

>In your example, what are the units of squaring a gallon tagged
>with temperature?

Squaring a gallon of anything I can think of has no meaning.

The importance of the temperature compensation example is to illustrate
that some apps may need multiple flavors of units (propane_gallons,
uncompensated_propane_gallons) which are very app specific and have very
fine grained distinctions which may be useless in other apps.

>How often do problems like this come up?

In industrial and commercial apps, quite often. Years ago I did some
programming for a stationary supplier, and they had to deal with some large
number of units-of-measure. I forget if it was 50 or 200, but it was a lot.
Think quires and reams, for example.

The petroleum industry examples have an physical safety aspect, too. You
can kill people with unit-of-measure mistakes. Confusion between aviation
gas and jet fuel is a classic example, although the cases I'm aware of were
human rather than computer error.

> Is it better to just let
>people with such problems make their own class that uses the unit
>library for the gallon part and implements the additional logic in
>the new class?

That might be a good, or even the best solution. But if so, it should
definitely be a use-case that is tested during development. Giving a
"how-to" example in the docs would help too.

--Beman


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