"Strong typing vs. strong testing"

Erik Max Francis max at alcyone.com
Wed Oct 13 00:29:05 CEST 2010


Thomas A. Russ wrote:
> "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".

It'd be just fine if your sine function took radians, which they pretty 
much all do.  If someone's computing an angle from the ratio from two 
distances, then he's already using radians, so that's just fine. 
Radians are defined in such a way that they _are_ dimensionless, there's 
no question about that.  We just mention the unit to help us keep track 
of things.

If you're talking about some other error, then it's far greater than 
using the unit system, and it's not likely the unit-enforcing system 
they'll work will help alone.  If you're calling a trigonometric 
function with a dimensionless argument, you either mean radians are 
you've got bigger problems with the understanding of unit systems.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   Don't want you to leave / And I don't want to leave you
    -- Chante Moore



More information about the Python-list mailing list