Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!pasteur!ucbvax!agate!shelby!csli!jkl From: jkl@csli.Stanford.EDU (John Kallen) Newsgroups: comp.lang.c Subject: Re: Pointer incrementation and assignme Message-ID: <9135@csli.Stanford.EDU> Date: 27 May 89 05:51:56 GMT References: <2015@csuna.csun.edu> <236100012@mirror> Sender: jkl@csli.Stanford.EDU (John Kallen) Reply-To: jkl@csli.stanford.edu (John Kallen) Organization: Center for the Study of Language and Information, Stanford U. Lines: 28 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <236100012@mirror> root@mirror.TMC.COM writes: >In reality >the command a++ is just shorthand for a+=1 and a = a+1. It was origionally >made for lines like: > > whatchamacallit = whatchamacallit + 1; > >Carnigan and Ritchie were programmers who didn't like to type. Kernighan and Ritchie might be lazy typists, but there's another for having += and ++ operators: I don't have it in front of me, but in the Bible there was an example of a hairy expression like: yylval[yylval1[i]][yylval2[i]] = yylval[yylval1[i]][yylval2[i]] + 1; which might very easily get corrupted inadvertently. Now, yylval[yyval1[i]][yylval2[i]] ++; is not only shorter code, but *safer*, and above all MUCH clearer. Useful little beasties, the assignment and the increment operators. John. _______________________________________________________________________________ | | | | |\ | | /|\ | John Kallen | |\ \|/ \| * |/ | |/| | | PoBox 11215 Support gun control - | |\ /|\ |\ * |\ | | | | Stanford CA 94309 Kill an NRA member! _|_|___|___|____|_\|___|__|__|_jkl@csli.stanford.edu___________________________