Re^2: C strongly typed?
house ron
s64421 at zeus.irc.usq.oz
Mon Mar 19 23:42:24 AEST 1990
rimvallm at jupiter.crd.ge.com (Magnus Rimvall) writes:
>In article <39941 at ism780c.isc.com> marv at 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 at zeus.irc.usq.oz.au)
(By post: Info Tech, U.C.S.Q. Toowoomba. Australia. 4350)
More information about the Comp.lang.c
mailing list