Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!gargoyle!ihnp4!alberta!myrias!cg From: cg@myrias.UUCP (Chris Gray) Newsgroups: comp.lang.c Subject: Re: Style [++i vs i++] Message-ID: <512@myrias.UUCP> Date: Thu, 2-Jul-87 13:04:41 EDT Article-I.D.: myrias.512 Posted: Thu Jul 2 13:04:41 1987 Date-Received: Sat, 4-Jul-87 11:15:10 EDT References: <17310@amdcad.AMD.COM> Organization: Myrias Research, Edmonton Lines: 43 I'm probably unusual, but I use pre-increment to increment pointer variables and += to increment numeric variables. I also separate out the increments, i.e. don't do them inside other expressions. E.g. char *p; int i; ... i = 0; while (*p != '\0') { process(*p); ++p; i += 1; } This will look ghastly to many C programmers, but I have my reasons. I use the two different increment forms because I like the added visual clues that one is a pointer and one is an integer (incrementing a pointer does not necessarily add 1, so I prefer not to see a '1'). I use the pre- increment form since the incrementation is the action being performed by the "statement" and I want to see the action before its operand. The biggest reason I have for doing things like this is quite simple - I program in other languages besides C, and C's idioms don't port to those languages. My poor brain would just get confused if I forced it to try to switch idioms on a twice daily basis (the other language changes and editor changes are bad enough), so I've developed a set of idioms that work in both of the languages I use a lot. The other language has a proper 'nil' and a proper 'bool' type, so I use those in C too. On the subject of 'if's - I would use if (! isdigit(ch)) ... and mentally read it as "if not isdigit ch then". I would also use if (p != NULL) ... One of the big problems with C's syntax from my point of view is that a lot of translation is needed to go between the C form and my internal mental form. -- Chris Gray Myrias Research, Edmonton +1 403 432 1616 {seismo!mnetor,ubc-vision,watmath,vax135}!alberta!myrias!cg