Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <22380@sun.uucp> Date: Tue, 30-Jun-87 01:05:36 EDT Article-I.D.: sun.22380 Posted: Tue Jun 30 01:05:36 1987 Date-Received: Sat, 4-Jul-87 18:51:14 EDT References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <10509@sri-spam.istc.sri.com> Sender: news@sun.uucp Lines: 44 Keywords: have my cake and eat it too > >2. Needless use of the comma operator and parenthesis to demonstrate > > manhood to the obliteration of code readability, e.g. > > if((fd=open("foo",1)<0) > > > > Once again to save instructions. The function return value is usually > already in d0, and it needs only check it's status bits for negative, > etc.. as opposed to loading -1 into another register, then comparing > the two register values. The "< 0" vs. "== -1" may make a difference in the generated code, but if the if ((fd = open("foo", 1)) < 0) vs. fd = open("foo", 1); if (fd < 0) makes a difference, you don't have a good compiler. Our compiler gives the exact same code for if ((fd = open("foo", 1)) < 0) die(); and fd = open("foo", 1); if (fd < 0) die(); namely, something similar to: pea 1 pea "foo" jbsr _open addqw #8,sp movl d0,fd jge 1f jbsr _die 1: Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com