Richard Bos wrote:

Chris Dollin <ch**********@hp.comwrote:

>Richard Bos wrote:

"ARMAS" <sm********@gmail.comwrote:

what's the difference between "y++" and "y=y+1"?

Ignoring stupid homework niggles, nothing whatsoever.

Um ... does

The value of the expression `y++` is the original

value of `y`, while the value of the expression `y=y+1`

is the new value of `y`.

count as a "stupid homework niggle"?

Yes.

OK. You niggle more than I, then.

_As written_, those two do the same thing. _In context_ they might

do completely different things - you might, for example, also #define y

call_a_complex_function(pointer_to_binary_tree) - but outside of

homework problems or job applications, I expect such a context to be

given with the problem.

I find this argument uncompelling, since the value of an expression

is an important property of it, and using the value of an expression

a very common context.

I note that the expressions `y++` and `(y++, 0)` do the same thing

as written, but would hesitate to describe their differences as

a niggle.

--

Chris "electric hedgehog" Dollin

"You're not supposed to /think/ about it, you're supposed to say NO!"

Jill Swinburn, /The Beiderbeck Connection/