Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!tada From: tada@athena.mit.edu (Michael Zehr) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <13184@bloom-beacon.MIT.EDU> Date: 1 Aug 89 13:41:59 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <10562@smoke.BRL.MIL> <1989Jul24.194646.3012@nc386.uucp> <5630@pt.cs.cmu.edu> <1989Jul28.174033.12734@jarvis.csri.toronto.edu> <918@helios.toronto.edu> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: tada@athena.mit.edu (Michael Zehr) Organization: Massachusetts Institute of Technology Lines: 29 In article <918@helios.toronto.edu> dooley@helios.physics.utoronto.ca (Kevin Dooley) writes: >Can anybody tell me if there is a usage where the comma is 'better'. >By this I mean are there any places where using a comma makes the >code more readable, efficient, produce cleaner/faster assembler (I >know this is compiler dependant). It's just that I've never seen a >program with the comma operator where I didn't scream and edit it out. >Am I being hopelessly pedestrian here? > I agree with you completely. People seem to use the comma operator to save lines of code and bytes of text files. It rarely makes a difference in the compiled code, and it does make it harder to read. If you debate the "harder to read" bit, consider this -- the comma essentially is like putting two statements on one line. would you rather read code like: puts("it broke."); exit(2); than: puts("it broke."); exit(2); I will qualify the "no comma" rule, though -- sometimes a comma is required in a macro in order to allow the macro to "return" a value. of course, this isn't making code much harder to read because it only appears in one place, and there is no other solution given the syntax of tha language. -michael j zehr