"Strong typing vs. strong testing"

Thomas A. Russ tar at sevak.isi.edu
Tue Oct 12 23:53:05 CEST 2010


"BartC" <bc at freeuk.com> writes:

> "Thomas A. Russ" <tar at sevak.isi.edu> wrote in message
> news:ymi1v7vgyp8.fsf at blackcat.isi.edu...
> > torbenm at diku.dk (Torben ZÆgidius Mogensen) writes:
> >
> >> Trigonometric functions do take arguments of particular units: radians
> >> or (less often) degrees, with conversion needed if you use the "wrong"
> >> unit.
> >
> > But radians are dimensionless.
> 
> But they are still units, so that you can choose to use radians, degrees
> or gradians for literals, so that functions that take angle arguments
> can verify they are angles and not just numbers, and so that they can be
> displayed appropriately.
> 
> You can't do all that if angles are just numbers.

But if you need to supply the units, that only really helps you when you
actually input them.  The problem comes when you have computed
quantities, such as you might get when trying to do more involved
computations.

If you have a system where 10m/1m => 10 then it means you couldn't have
a calculation like 100km*sin(10m/1m) and have it work, because the
dimensionless 10 that you get from the calculation would be incorrect.
You would have to know something else about the division in order to get
the correct dimensionless "units".

This is also an issue in sorting out torque and work, since they also
have the same base units.  You can't really tell if N*m is supposed to
be a measure of work or of torque, which also means that you can't use
that to distinguish the results of such a multiplication just by using
dimensional analysis.  Often it works, but sometimes you just run into
ambiguity, so IMHO you have to live with that ambiguity in order to
build a computational system that really works.

-- 
Thomas A. Russ,  USC/Information Sciences Institute



More information about the Python-list mailing list