Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!lavaca.uh.edu!menudo.uh.edu!sugar!ficc!peter From: peter@ficc.ferranti.com (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: Increment Operators vs. Precedence Message-ID: Date: 7 Mar 91 23:44:39 GMT References: Reply-To: peter@ficc.ferranti.com (Peter da Silva) Organization: Xenix Support, FICC Lines: 27 In article thomson@zazen.macc.wisc.edu (Don Thomson) writes: > The example on the board is y = x++, and I explain that x gets > assigned to y before x is incremented. So you used loose terminology. And confused them. What you meant was that the value of x as it was before incrementing is assigned to y. X may in fact have been assigned first, as in: y[x] = x++ which has an undefined result. > So the dilemma is how to explain that > precedence is not the issue here, that the order of operations is tied to the > definition of prefix versus postfix increment operators. Don't explain that, because it's not in fact true. If you leave them believing that they will believe the expression I gave above has a defined result. Explain it in terms of expressions, their values, and side effects: "x++" is an expression that returns the value of x as it was before incrementing, and as a side effect increments x. Precedence is not the issue, but neither is the order of operations. -- Peter da Silva. `-_-' peter@ferranti.com +1 713 274 5180. 'U` "Have you hugged your wolf today?"