Xref: utzoo comp.lang.c:26853 comp.lang.misc:4428 Path: utzoo!attcan!uunet!lll-winken!uwm.edu!mailrus!ncar!ico!ism780c!news From: news@ism780c.isc.com (News system) Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: C strongly typed? Message-ID: <39941@ism780c.isc.com> Date: 13 Mar 90 01:35:56 GMT References: <259@eiffel.UUCP) <1990Mar1.172526.28683@utzoo.uucp) <849@enea.se) <1990Mar7.182230.5517@utzoo.uucp) <862@enea.se> Reply-To: marv@ism780.UUCP (Marvin Rubenstein) Organization: Interactive Systems Corp., Santa Monica CA Lines: 25 In article <862@enea.se> sommar@enea.se (Erland Sommarskog) writes: > >Well, apparently I am allowed to mix apples and oranges. If I have >two types of data that both happens to be represented by integers, >but have no logical connection what so ever I cannot apparently >express that in C. And consequently I cannot take help from the >compiler to catch inadvertent mixups in for instance procedure calls. > 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