<?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: Variable interchange</title>
	<atom:link href="http://blog.motane.lu/2009/01/19/variable-interchange/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu/2009/01/19/variable-interchange/</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ionut G. Stan</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-357</link>
		<dc:creator>Ionut G. Stan</dc:creator>
		<pubDate>Wed, 15 Apr 2009 14:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-357</guid>
		<description>Just saw what Radu said...

Radu, that is basically the same thing as the list/array solution in PHP. Python though, has the advantage of some syntactic sugar for declaring tuples, so one doesn&#039;t have to write the parens. That&#039;s all. Is there a bigger difference and I&#039;m not yet seeing it?</description>
		<content:encoded><![CDATA[<p>Just saw what Radu said&#8230;</p>
<p>Radu, that is basically the same thing as the list/array solution in PHP. Python though, has the advantage of some syntactic sugar for declaring tuples, so one doesn&#8217;t have to write the parens. That&#8217;s all. Is there a bigger difference and I&#8217;m not yet seeing it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radu</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-155</link>
		<dc:creator>Radu</dc:creator>
		<pubDate>Thu, 05 Feb 2009 22:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-155</guid>
		<description>Sore loser?!</description>
		<content:encoded><![CDATA[<p>Sore loser?!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-154</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Thu, 05 Feb 2009 21:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-154</guid>
		<description>I&#039;ve got it! You can interchange variables in this manner in python and in php you cannot. Now get over it...</description>
		<content:encoded><![CDATA[<p>I&#8217;ve got it! You can interchange variables in this manner in python and in php you cannot. Now get over it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radu</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-153</link>
		<dc:creator>Radu</dc:creator>
		<pubDate>Thu, 05 Feb 2009 21:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-153</guid>
		<description>You can do that with any data structure in Python (simple variable, lists, tuples, dictionaries).</description>
		<content:encoded><![CDATA[<p>You can do that with any data structure in Python (simple variable, lists, tuples, dictionaries).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-152</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:10:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-152</guid>
		<description>I have to agree that that&#039;s pretty neat...</description>
		<content:encoded><![CDATA[<p>I have to agree that that&#8217;s pretty neat&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radu</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-150</link>
		<dc:creator>Radu</dc:creator>
		<pubDate>Thu, 05 Feb 2009 18:13:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-150</guid>
		<description>Btw, in Python (I am a big Python fan) you would just write
[code lang=&quot;php&quot;]
a, b = b, a
[/code]

How cool is that? :D</description>
		<content:encoded><![CDATA[<p>Btw, in Python (I am a big Python fan) you would just write</p>
<pre class="brush: php; title: ; notranslate">
a, b = b, a
</pre>
<p>How cool is that? <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ionut G. Stan</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-109</link>
		<dc:creator>Ionut G. Stan</dc:creator>
		<pubDate>Thu, 29 Jan 2009 00:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-109</guid>
		<description>Raul, I have to disagree with you for a couple of reasons:

1. That trick is slower than a temporary variable, but the time required to execute that assignment probably takes less than is needed for a fly to flip its wings once.
2. Following the same logic, objects and functions are probably bad because they introduce overhead, while simple global code does not.

There is a threshold when you really have to care about such optimizations, most likely after optimizing database access and heavy algorithms.

Also, comments are best for user programmers (by generating documentation from phpdoc comments), who want to use a certain library but don&#039;t want to dive the source code. Additionally, comments *must* be used for hard to understand algorithms. Regardless of the above though, the API should talk for itself.

Finally, a temporary variable is probably the way to go, every PHP newbie would understand such a piece of code, but as the &quot;overhead&quot; introduced is so small it basically becomes a matter of taste. As it is with echo vs. print and single quotes vs. double quotes.</description>
		<content:encoded><![CDATA[<p>Raul, I have to disagree with you for a couple of reasons:</p>
<p>1. That trick is slower than a temporary variable, but the time required to execute that assignment probably takes less than is needed for a fly to flip its wings once.<br />
2. Following the same logic, objects and functions are probably bad because they introduce overhead, while simple global code does not.</p>
<p>There is a threshold when you really have to care about such optimizations, most likely after optimizing database access and heavy algorithms.</p>
<p>Also, comments are best for user programmers (by generating documentation from phpdoc comments), who want to use a certain library but don&#8217;t want to dive the source code. Additionally, comments *must* be used for hard to understand algorithms. Regardless of the above though, the API should talk for itself.</p>
<p>Finally, a temporary variable is probably the way to go, every PHP newbie would understand such a piece of code, but as the &#8220;overhead&#8221; introduced is so small it basically becomes a matter of taste. As it is with echo vs. print and single quotes vs. double quotes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-106</link>
		<dc:creator>Raul</dc:creator>
		<pubDate>Wed, 28 Jan 2009 19:46:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-106</guid>
		<description>Writing 3 lines or even 300 lines of comments where it is needed it&#039;s a good ideea! ;)</description>
		<content:encoded><![CDATA[<p>Writing 3 lines or even 300 lines of comments where it is needed it&#8217;s a good ideea! <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-92</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Wed, 28 Jan 2009 06:10:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-92</guid>
		<description>Nope. Comments are useful when all the functionality in encapsulated in a function or a method of class. You&#039;ll have something like:
[code lang=&quot;php&quot;]
/**
 * does whatever
 * 
 * @param string $_param1
 * @param string $_param2
 * @return array
 */
function myFunction( $_param1, $_param2 ) {
    /* voodoo */
    return $result;
}
[/code]

Due to the comments and phpdoc tags, this function would be easy to use. You know what it does. But when you need to change the &quot;content&quot; of the function or how it does its stuff, code readability is a very important issue.

And beside, writing 3 lines of comments after each line of code just because you wanted to try an &quot;elegant&quot; and &quot;original&quot; approach is lame...</description>
		<content:encoded><![CDATA[<p>Nope. Comments are useful when all the functionality in encapsulated in a function or a method of class. You&#8217;ll have something like:</p>
<pre class="brush: php; title: ; notranslate">
/**
 * does whatever
 *
 * @param string $_param1
 * @param string $_param2
 * @return array
 */
function myFunction( $_param1, $_param2 ) {
    /* voodoo */
    return $result;
}
</pre>
<p>Due to the comments and phpdoc tags, this function would be easy to use. You know what it does. But when you need to change the &#8220;content&#8221; of the function or how it does its stuff, code readability is a very important issue.</p>
<p>And beside, writing 3 lines of comments after each line of code just because you wanted to try an &#8220;elegant&#8221; and &#8220;original&#8221; approach is lame&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul</title>
		<link>http://blog.motane.lu/2009/01/19/variable-interchange/comment-page-1/#comment-89</link>
		<dc:creator>Raul</dc:creator>
		<pubDate>Tue, 27 Jan 2009 22:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=258#comment-89</guid>
		<description>Yes, I think I know what you mean!
Still, readability can be achieved by adding comments, after all, isn&#039;t it?</description>
		<content:encoded><![CDATA[<p>Yes, I think I know what you mean!<br />
Still, readability can be achieved by adding comments, after all, isn&#8217;t it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

