Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!rebel!george From: george@rebel.UUCP (George M. Sipe) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: <751@rebel.UUCP> Date: 23 Jul 89 15:34:41 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <10103@mpx2.mpx.com> <14580@dartvax.Dartmouth.EDU> <37@ark1.nswc.navy.mil> Reply-To: george@rebel.UUCP (George M. Sipe) Organization: not yet Lines: 45 In article <37@ark1.nswc.navy.mil> dpaulso@ark1.nswc.navy.mil writes: >In article <14580@dartvax.Dartmouth.EDU> ari@eleazar.dartmouth.edu (Ari Halberstadt) writes: >>[...] >> return(perror("it failed"), FALSE); >>This saves the nuisance of using braces and two statements. > > I don't usually like to complain about other people's coding >preferences, but this just struck a nerve. > > This is just plain ugly. When *I* see a comma operator, I tend to think >of two things being done in parallel, so the impression I get when You see it wrong thing then. What you should see are two sequential operations. You are specifically assured of that. As for ugly, perhaps a better word would be unfamiliar. I personally haven't been (usually) coding that way, so it makes me think for a second when I see it. In some ways its more expressive. In the right frame of mind it may even be clearer. It seems to me that the comma operator is one of those elements of C which is not (at least) frequently seen in other languages, which fill a very useful role. It's sort of like comparing: some_very_long_variable_name = some_very_long_variable_name + 3; vs. some_very_long_variable_name += 3; You don't have to do it the second way. You could say the second way is ugly. You could argue that the first way is a "standard" method. Yet the second approach many would say is clearer. There is no confusion compared to the first approach where you would have to be careful that the same variable was referenced: some_very_long_variable_name = some_long_very_variable_name + 3; With the expressiveness of +=, you immediately see what is happening. I think the comma operator falls into that category as well, once you get confortable with it. -- George M. Sipe, Phone: (404) 447-4731 537 Lakeshore Drive, Berkeley Lake, GA 30136-3035 UUCP: ...!{decvax,linus,rutgers}!gatech!rebel!george