<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: i += i++ + ++i;</title>
	<atom:link href="http://www.herrodius.com/blog/47/feed" rel="self" type="application/rss+xml" />
	<link>http://www.herrodius.com/blog/47</link>
	<description>Thoughts from a software developer</description>
	<lastBuildDate>Wed, 30 Nov 2011 09:13:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Palatis</title>
		<link>http://www.herrodius.com/blog/47/comment-page-1#comment-14844</link>
		<dc:creator>Palatis</dc:creator>
		<pubDate>Sat, 26 Mar 2011 07:58:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=47#comment-14844</guid>
		<description>This is pretty much an unspecified behavior.
It depends on how the compiler/interpreter implements the + and postfix ++ operators. (and they&#039;re free to NOT document these orders.)

see:
http://en.wikipedia.org/wiki/Sequence_point</description>
		<content:encoded><![CDATA[<p>This is pretty much an unspecified behavior.<br />
It depends on how the compiler/interpreter implements the + and postfix ++ operators. (and they&#8217;re free to NOT document these orders.)</p>
<p>see:<br />
<a href="http://en.wikipedia.org/wiki/Sequence_point" rel="nofollow">http://en.wikipedia.org/wiki/Sequence_point</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristof</title>
		<link>http://www.herrodius.com/blog/47/comment-page-1#comment-1769</link>
		<dc:creator>Kristof</dc:creator>
		<pubDate>Mon, 29 May 2006 00:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=47#comment-1769</guid>
		<description>@ caprica: Depends on your definition of right.

Actionscript:
var i = 1;
i += ++i;
trace(i); // traces 3
//is equivalent to
var i = 1;
var oldi = i;
var x = ++i;
i = oldi + x;
trace(i); //traces 3

Php:
$i = 1;
$i += ++$i;
echo &#039;i = &#039;, $i, &#039;&lt;br&gt;&#039;; // echos 4
//is equivalent to
$i = 1;
$x = ++$i;
$i = $i + $x;
echo &#039;i = &#039;, $i, &#039;&lt;br&gt;&#039;; // echos 4

Ruby:
Ruby doesn&#039;t support the increment operator.
So you can write ++ all you want, it will just ignore you.

Each of these approaches makes sense, they just happen to differ.</description>
		<content:encoded><![CDATA[<p>@ caprica: Depends on your definition of right.</p>
<p>Actionscript:<br />
var i = 1;<br />
i += ++i;<br />
trace(i); // traces 3<br />
//is equivalent to<br />
var i = 1;<br />
var oldi = i;<br />
var x = ++i;<br />
i = oldi + x;<br />
trace(i); //traces 3</p>
<p>Php:<br />
$i = 1;<br />
$i += ++$i;<br />
echo &#8216;i = &#8216;, $i, &#8216;&lt;br&gt;&#8217;; // echos 4<br />
//is equivalent to<br />
$i = 1;<br />
$x = ++$i;<br />
$i = $i + $x;<br />
echo &#8216;i = &#8216;, $i, &#8216;&lt;br&gt;&#8217;; // echos 4</p>
<p>Ruby:<br />
Ruby doesn&#8217;t support the increment operator.<br />
So you can write ++ all you want, it will just ignore you.</p>
<p>Each of these approaches makes sense, they just happen to differ.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: caprica</title>
		<link>http://www.herrodius.com/blog/47/comment-page-1#comment-1752</link>
		<dc:creator>caprica</dc:creator>
		<pubDate>Sat, 27 May 2006 16:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=47#comment-1752</guid>
		<description>It seems that only actionscript, javascript, java and vbscript does this right ?

i = 1
i += i++ + ++i

first operate on the right side :

1st operation i++ =&gt; right_ans = 2
2nd operation + (i is still 1)  =&gt; right_ans = 2 + 1 = 3
3rd operation  ++i =&gt; right_ans = 3 + 1 = 4

then operate on the left side :

i = i + right_ans = 1 + 4 = 5</description>
		<content:encoded><![CDATA[<p>It seems that only actionscript, javascript, java and vbscript does this right ?</p>
<p>i = 1<br />
i += i++ + ++i</p>
<p>first operate on the right side :</p>
<p>1st operation i++ =&gt; right_ans = 2<br />
2nd operation + (i is still 1)  =&gt; right_ans = 2 + 1 = 3<br />
3rd operation  ++i =&gt; right_ans = 3 + 1 = 4</p>
<p>then operate on the left side :</p>
<p>i = i + right_ans = 1 + 4 = 5</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristof</title>
		<link>http://www.herrodius.com/blog/47/comment-page-1#comment-1750</link>
		<dc:creator>Kristof</dc:creator>
		<pubDate>Sat, 27 May 2006 15:42:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=47#comment-1750</guid>
		<description>In actionscript, javascript, java and vbscript it is 5

var i:Number;
i = 1;
i += i++ + ++i;
trace(&quot;i = &quot;+i);

i = 1;
i = i+i+(i+1);
i++;
trace(&quot;i = &quot;+i);

i = 1;
i = 3*i+2;
trace(&quot;i = &quot;+i);

In php and c++ however this would be 7 ...

&#039;;

$i = 1;
$i++;
$i = $i + $i + $i;
$i++;
echo &#039;i = &#039;, $i, &#039;&#039;;

$i = 1;
$i = (3 * ($i + 1)) + 1;
echo &#039;i = &#039;, $i, &#039;&#039;;
?&gt;

And in ruby it would be 3.

i = 1
i += i++ + ++i
puts &#039;i = &#039; + i.to_s

i = 1
i = 3 * i
puts &#039;i = &#039; + i.to_s

My head hurts.</description>
		<content:encoded><![CDATA[<p>In actionscript, javascript, java and vbscript it is 5</p>
<p>var i:Number;<br />
i = 1;<br />
i += i++ + ++i;<br />
trace(&#8220;i = &#8220;+i);</p>
<p>i = 1;<br />
i = i+i+(i+1);<br />
i++;<br />
trace(&#8220;i = &#8220;+i);</p>
<p>i = 1;<br />
i = 3*i+2;<br />
trace(&#8220;i = &#8220;+i);</p>
<p>In php and c++ however this would be 7 &#8230;</p>
<p>&#8216;;</p>
<p>$i = 1;<br />
$i++;<br />
$i = $i + $i + $i;<br />
$i++;<br />
echo &#8216;i = &#8216;, $i, &#8221;;</p>
<p>$i = 1;<br />
$i = (3 * ($i + 1)) + 1;<br />
echo &#8216;i = &#8216;, $i, &#8221;;<br />
?&gt;</p>
<p>And in ruby it would be 3.</p>
<p>i = 1<br />
i += i++ + ++i<br />
puts &#8216;i = &#8216; + i.to_s</p>
<p>i = 1<br />
i = 3 * i<br />
puts &#8216;i = &#8216; + i.to_s</p>
<p>My head hurts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philippe</title>
		<link>http://www.herrodius.com/blog/47/comment-page-1#comment-1744</link>
		<dc:creator>Philippe</dc:creator>
		<pubDate>Sat, 27 May 2006 11:02:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=47#comment-1744</guid>
		<description>Haha, nice!
I guessed the correct result.</description>
		<content:encoded><![CDATA[<p>Haha, nice!<br />
I guessed the correct result.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

