Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!bellcore!att!cbnewsh!ho5cad!wjc From: wjc@ho5cad.ATT.COM (Bill Carpenter) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: Date: 19 Jul 89 17:26:02 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> Sender: bill@cbnewsh.ATT.COM Reply-To: wjc@ho5cad.ATT.COM (Bill Carpenter) Organization: AT&T Bell Laboratories Lines: 28 In-reply-to: erik@mpx2.mpx.com's message of 19 Jul 89 12:18:05 GMT In article <10100@mpx2.mpx.com> erik@mpx2.mpx.com (Erik Murrey) writes: > struct xyzzy *sptr; > if (sptr= my_function(), sptr->x == 0) > printf("x is zero\n"); > > I think the second is much clearer. This looks even better as the > pointers get more complex, since the pointer operators go right > on the ptr itself, and not on an expression. Since there was no indication that this was intended as a joke ... I'll admit that this cloudy fragment looks clearer than the other one you cited, but what the heck is wrong with (besides not checking "sptr" being null): struct xyzzy *sptr; sptr= my_function(); if (sptr->x == 0) printf("x is zero\n"); Surely this "looks even better as the pointers get more complex" and the whole expression would otherwise dance off the left edge of the page? Why make the code hard to read when there isn't even a payoff? Is the point to show your pals in the Code Maintenance Garage that you know all about the comma operator? Or are you one of those poeple who gets paid proportional to the inverse number of source lines? :-) -- Bill Carpenter att!ho5cad!wjc or attmail!bill