Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!think.com!paperboy!hsdndev!cmcl2!lanl!beta.lanl.gov.!mikeg From: mikeg@c3.c3.lanl.gov (M. P. Gerlek) Newsgroups: comp.lang.c Subject: Re: Dealing with pointer freaks Message-ID: Date: 25 Jun 91 15:31:37 GMT References: <6470@goanna.cs.rmit.oz.au> <2075@manta.NOSC.MIL> Sender: news@lanl.gov Distribution: comp Organization: Los Alamos National Laboratory, New Mexico Lines: 51 In-reply-to: sherman@unx.sas.com's message of 25 Jun 91 10:02:31 GMT In article sherman@unx.sas.com (Chris Sherman) writes: > IMHO, leave the dude alone. Jump up and down when you find major problems > [...] > but for things like *(x+i), don't worry about it. Yes, x[i] is just *(x+i), but consider what x[a][b+k][j+1] turns into. I can't believe more than a handful of you could look at the "pointer-ized" expression for x[a][b+k][j+1] and *immediately* tell what it means. We're considering readability of code, here. As an example, consider coding some sort of numerical, linear algebra sort of algorithm. The mathematical expression can be fairly quickly translated into C, substituting x-sub-i-sub-j ("x_ij") for x[i][j]. It's not obvious to the subsequent reader of the code that the expression *(*(x+i)+j) is simply x[i][j], however. You've lost 'readability'. I'm amazed at the number of comments I've rec'd about using pointers *instead of* simple array syntax. Tell me it's just that I'm not hearing a representative sample -- I refuse to believe the majority of the net feels that there's no point in conforming to one set style because, to quote some email, (a) there are too many styles, (b) if YOU write the code YOU can do it however YOU want, and (c) anyone using the code later should be able to just clean up the parts he or she doesn't like. (This last is particularly amazing :-) Yes, I will grant that if the peiece of code you are doing is a one-man project you can code it however you like -- but what happens after you've left the shop, and someone else needs to use it? Further, to get back to my original post, we're dealing with a case where the programmer is programming solo _today_, but will be writing code that he and others will have to port and modify _tomorrow_. Finally, I've gotten responses saying that the Indian Hill style guide is out-of-date and flat out wrong in places. Will someone please post a critique of the I.H. guide? And please tell me what y'all use instead? If anything? And as an aside to those of you who don't like "conventions" and "styles" in C: do you put your #defined constants in all uppercase? You do? Care to explain why? -[mpg] mikeg@lanl.gov "Headline: LANL High-speed Compooter Researchers Pay Raft Trip Subsidies" -- -[mpg] mikeg@lanl.gov "Headline: LANL High-speed Compooter Researchers Pay Raft Trip Subsidies"