Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!sundc!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: comp.lang.c Subject: Re: Why are typedef names in the same name space as variable names? Message-ID: <625@hadron.UUCP> Date: Sun, 23-Nov-86 17:22:23 EST Article-I.D.: hadron.625 Posted: Sun Nov 23 17:22:23 1986 Date-Received: Mon, 24-Nov-86 21:53:03 EST References: <1092@spice.cs.cmu.edu> <307@cartan.Berkeley.EDU> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Distribution: net Organization: Hadron, Inc., Fairfax, VA Lines: 33 Summary: Objection to objection. In article <307@cartan.Berkeley.EDU> ballou@brahms (Kenneth R. Ballou) writes: >In article <1092@spice.cs.cmu.edu> jgm@spice.cs.cmu.edu (John Myers) writes: >>In article <4220@ut-ngp.UUCP> dlnash@ut-ngp.UUCP (Donald L. Nash) writes: >>>Why are typedef names in the same name space as variable names?... >>#include >>main() >>{ >> typedef car foo; >> long foo; >> printf("%d\n",sizeof(foo)); >>} >I don't see that there is a question here. Sizeof is *NOT* a function, as was >quite thoroughly discussed some time back in this group. Note that (foo) in >this case is the syntax of a type cast, and in this case, sizeof returns >the size of a datum of type foo (in this case, 1). (foo) is also an expression. If the typedef were not present, this would still be a legal C program, with an unambiguous compilation: the size of the long int "foo" would be printed out. As it is, I believe either interpretation is "correct". Thus, purely BTW, this can be considered a bad program -- I think it's not a good idea to use a name for more than one purpose, when a less ambiguous way of doing the same thing can be found. As I mentioned before, to keep people honest and as MY OWN PERSONAL preference of style, I use the parentheses in both cases. (Emphasis mine, not zippy's or root boy's -- don't flame if it's just not your own personal style.) -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)