Xref: utzoo comp.lang.c:26795 comp.lang.misc:4406 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!psuvax1!psuvm!cmh117 From: CMH117@psuvm.psu.edu (Charles Hannum) Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: C strongly typed? Message-ID: <90070.034113CMH117@psuvm.psu.edu> Date: 11 Mar 90 08:41:13 GMT References: <259@eiffel.UUCP> <1990Mar1.172526.28683@utzoo.uucp> <849@enea.se> <1990Mar7.182230.5517@utzoo.uucp> <1798@gannet.cl.cam.ac.uk> Organization: Penn State University Lines: 56 In article <1798@gannet.cl.cam.ac.uk>, nmm@cl.cam.ac.uk (Nick Maclaren) says: > >The ANSI standard (and K&R) explicitly require that any data type may be >treated as an array of characters ... >the above). This is simply not true! See below ... > A huge proportion of the library relies upon this to work at >all (e.g. much of string.h, some of stdlib.h, some of stdio.h). Well, everything in string.h works with arrays of characters; what's your point? As for stdlib.h and stdio.h, see comments on the void type below ... > union {void *a; char *b;} fred; > fred.a = ...; > ... = fred.b; What is wrong with this? First, this would only work if "..." was another void pointer or a char pointer. You seem to be bashing C for the inclusion of a void type ... "void" in C is similar to "nil" in LISP. It's just a generic type, which can hold the place of any other type, WHEN USED IN A POINTER!! I couldn't assign a character to a void type, for example. But I *can* assign a void pointer to a character pointer, and vice versa. This is part of the power of the C language. It simplifies things like malloc(), for example. And void has *nothing* to do with char! Try this: #include int main(void) { printf("%d %d\n",sizeof(void),sizeof(char)); } (Actually, my code sample above *does* show a deficiency in the C language; let's see if anyone can figure out what it is.) >[rest of gibberish deleted] Personally, I'm more concerned about the fact that this stupid terminal's "0" key on the keypad isn't working. It causes a lot more problems than a void type. Virtually, - Charles Martin Hannum II "Klein bottle for sale ... inquire within." (That's Charles to you!) "To life immortal!" cmh117@psuvm.{bitnet,psu.edu} "No noozzzz izzz netzzzsnoozzzzz..." c9h@psuecl.{bitnet,psu.edu} "Mem'ry, all alone in the moonlight ..."