[comp.lang.c] Re^2: C strongly typed?

s64421@zeus.irc.usq.oz (house ron) (03/19/90)

rimvallm@jupiter.crd.ge.com (Magnus Rimvall) writes:

>In article <39941@ism780c.isc.com> marv@ism780.UUCP (Marvin Rubenstein) writes:
>>I am unaware of any commonly available language that prevents this form of
>>mistake.  Look at the following:
>>
>>  double distance;
>>  double time;
>>  double velocity;
>>
>>  velocity = distance/time;  /* this makes sense */
>>  velocity = distance+time;  /*  I mixed 'apples' and 'oranges' and produced
>>				 a lemon :-) */
>>
>>I did read a paper (sorry, I don't have the reference) describing a language
>>that allowed one to augment the the type declaration with a units declaration
>>so as to be able to catch errors of this form.
>>
>>   Marv Rubinstein

>...

>The task of unit tests is, at least in the USA, only half the
>battle. Until the metric system is adopted, we would also need
>automatic scaling of units 

In 1983 I wrote a paper explaining exactly how to solve this entire
problem, including automatic conversions between different units with
the same dimensions.  It all works at compile time, even with functions
etc. in different files.  The reference is:

A proposal for an extended form of type checking of expressions.
R.T. House.  The Computer Journal, V26, no 4 1983.

The paper shows how to do it to Pascal, but the method works for
any strongly typed language.

Surely it's about time someone took this problem as seriously as
confusions between strings/reals etc, and extended the common
languages (especially scientific ones) to do it right.  After
all, the problem is solved!

Regards,

Ron House.   (s64421@zeus.irc.usq.oz.au)
(By post: Info Tech, U.C.S.Q. Toowoomba. Australia. 4350)