Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2005-10-20 14:31:20

Matt Calabrese wrote:
> Adding a length with another length always makes sense. It's a higher level
> of abstraction entirely specific to individual project which might make you
> believe otherwise. Forcing explicit conversions does not solve this.

I'm not arguing conceptual matters. Yes, I know adding lengths in inches
to lengths in meters makes sense. But is it good, clean code?

In some sense, I consider this to be analogous to the difference between
the strong type checking of C++ and the "anything goes" approach of,
say, Perl. Somehow, for me, automatic unit conversion seems like a good
fit with Perl but not with C++.

> On 10/20/05, Deane Yang <deane_yang_at_[hidden]> wrote:
>> Is it really sometimes necessary or desirable to write computation code
>> that mixes different units for the same dimension? Is anyone patient and
>> indulgent enough to explain to this naive mathematician why?
> I am standing on a stool that is 3 feet high. I am 1.6 meters tall. Adding
> the heights together describes how high above the ground I reach when
> standing on the stool. ..

I'm looking for an example of software design, not a toy textbook problem.

> Again, all of the "problems" you describe have nothing to do with the units
> used, but rather occur because of an unrepresented abstraction in your
> specific project. Encapsulate the different types separately if you want
> that abstraction as it has no place in a units library as I see it.

But why? The underlying concepts of vector and point quantities apply
just as well to my needs as it does to yours. The only difference is
that you want to define a certain collection of dimensions, and I want
to use a different collection. What's the difference?

Boost list run by bdawes at, gregod at, cpdaniel at, john at