Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "BartC" Newsgroups: comp.programming Subject: Re: Pre And Post Increment Operator Output Date: Fri, 22 Jun 2012 21:35:16 +0100 Organization: A noiseless patient Spider Lines: 1 Message-ID: References: <8404c4f1-a3b7-46b7-ad9c-17de265f9aee@googlegroups.com> <0.06d3eacd14619c86d384.20120622143458BST.87ehp7o4fx.fsf@bsb.me.uk><7MudnTZhnIs6EnnSnZ2dnUVZ_qCdnZ2d@earthlink.com> <0.0b3aeb4b00dfdccbd115.20120622205336BST.87395nnmwv.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Injection-Date: Fri, 22 Jun 2012 20:36:55 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="g02lTOQ/PuOntaKLE4vnTw"; logging-data="12713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Yvz56B1+ZFa+QhrX3KBO1" X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726 In-Reply-To: <0.0b3aeb4b00dfdccbd115.20120622205336BST.87395nnmwv.fsf@bsb.me.uk> X-Antivirus-Status: Clean X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726 Importance: Normal X-Antivirus: avast! (VPS 120622-0, 22/06/2012), Outbound message Cancel-Lock: sha1:tq/JKM7NP4cRezSjTD4a166k+iY= X-Priority: 3 X-MSMail-Priority: Normal Xref: csiph.com comp.programming:1857 "Ben Bacarisse" wrote in message news:0.0b3aeb4b00dfdccbd115.20120622205336BST.87395nnmwv.fsf@bsb.me.uk... > "BartC" writes: >> "Patricia Shanahan" wrote in message >>> On 6/22/2012 8:02 AM, BartC wrote: >>>> result of i=(++i)+(++i)+(++i), when i starts at 0 >>> In Java, i does have a specified resulting value. The effect will be the >>> same as i=3*i+6. >> >> So it ends up with i=6, when i starts at zero. The case for '6' is >> improving.. > > The case for 6 in Java is rock-solid. > > >> I suggested in comp.lang.c that the result of the above ought to be 6, >> in line with the original poster's expectations, (before going on to >> explain why it might not be in C), for which I was castigated and even >> called evil. > > Way to go BartC. Maybe the OP in the original thread had a Java background. Or maybe he just decided the common-sense result was 6, and wanted to know why C didn't agree. But I give up; you win. Clearly if someone sees such an expression, even before they go anywhere near an actual programming language, they have to assume that *expecting* a result such as 94613277, is just as plausible as expecting it to be as 6. (BTW how did Java, a C derivative, end up with well-defined semantics for this kind of expression? And why isn't the result 94613227, but... 6? Why choose 6? Because, after all, you guys keep telling me that i = (++i)+(++i)+(++i) is completely meaningless. Or is it conceivable that 6 does, after all, actually make more sense than 94613277..) Anyway, I'll leave you guys to it. -- Bartc