Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!uhccux!munnari.oz.au!goanna!ok From: ok@goanna.oz.au (Richard O'keefe) Newsgroups: comp.lang.c Subject: Re: C strongly typed? Message-ID: <2966@goanna.oz.au> Date: 9 Mar 90 00:09:58 GMT References: <2963@goanna.oz.au> <259@eiffel.UUCP> <1990Mar8.142433.13559@ncsuvx.ncsu.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 44 Concerning whether C is strongly typed; I gave Pascal and Ada equivalents of the fragment which was alleged to show C not to be strongly typed. In article <1990Mar8.142433.13559@ncsuvx.ncsu.edu>, jwb@cepmax.ncsu.EDU (John W. Baugh Jr.) writes: > I think the issue here is "type equivalence," ... > ... ISO/ANSI Pascal standard defines equivalence based on name. > > type > t1 = array[1..3] of boolean; > t2 = array[1..3] of boolean; > var > v1 : t1; > v2 : t2; > > the types of v1 and v2 are distinct under name equivalence, but equal > under structural equivalence. Quite right. But it isn't relevant to the example under discussion. Remember, the C fragment was typedef int apple, orange; apple a; orange b; a = b; The Pascal equivalent of such a typedef is type = ; and that does NOT introduce a new name. For example, type t1 = array[1..3] of boolean; t2 = t1; (* NO NEW TYPE IS INTRODUCED HERE *) var v1: t1; v2: t2; begin v2 := v1; is perfectly legal Pascal. Someone else claimed that the fact that char c; int i; i = c; or something like that is legal C also shows that C is not strongly typed. Again, Pascal and Ada are exactly the same. The Pascal equivalent of C's "char" is const minChar = {-128, or 0, or what have you}; maxChar = {127, or 255, or what have you}; type cChar = minChar..maxChar; The fact that var c: cChar; i: integer; begin i := c; is legal is not normally held to show that Pascal is not strongly typed; why should the same fact be held against C? True, C has no equivalent of Pascal's character type, but the absence of an equivalent for some other language's data type is not fatal to being strongly typed.