Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-09 01:40:26


Matthias Schabel wrote:
> These problems go away if you require explicit conversions. I know
> Andy wants automagic conversions, but I still think that the costs far
> outweigh the benefits for reasons like the above. In addition, the
> more explicit the units are the less likely errors are to arise when
> code is later cannibalized, rewritten, cut-n-pasted, etc... into
> contexts for which it was not originally intended...

Amen!

I've got another reason for wanting no dimension types:

In a long computation, one may need to store temporaries of unforseen
dimension types. E.g.: (furlongs/wavenumber)^(-7/11), and store that in
a named variable. I wouldn't want to declare and name such dimensional
type, and as far as the unit library's checks for consistency, etc., it
shouldn't be necessary.

And I've got another argument for why each unit type should represent
itself as one:

Back to the circuit layout CAD problem, combining millimeters and mils:
If the library were to force conversions to one or the other, it would
incurr cumulative errors in the non-default units system. I.e.: If we
select millimeters as the default, and I have a long connector whose
pins are spaced 50 mils apart, if I accumulate 50 mils many times, and
each time it is converted to millimeters and then added to an
accumulator, the error in each conversion is cumulative. If I select
mils as the default, and I have another long connector on the other side
of the board, and its pins are spaced 1.5 mm apart, same thing will
happen: conversion to mils each time (which is also inefficient, BTW),
and the error in each conversion is cumulative.

Cheers!


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