<?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: PHP Named Parameters</title>
	<atom:link href="http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Fri, 05 Mar 2010 05:20:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jaimie Sirovich</title>
		<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/comment-page-1/#comment-2747</link>
		<dc:creator>Jaimie Sirovich</dc:creator>
		<pubDate>Fri, 08 Jan 2010 06:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=227#comment-2747</guid>
		<description>This is similar to what we&#039;ve done, but we used different elbow-grease.  See -- &lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.seoegghead.com/software/downloads/php-parameter-skipping-and-named-parameters.php&quot; rel=&quot;nofollow&quot;&gt;http://www.seoegghead.com/software/downloads/ph...&lt;/a&gt;&lt;br&gt;&lt;br&gt;We hijack the parameter list via an include.  It&#039;s a hack, but it&#039;s elegant, and it&#039;s always the same cut-and-pasted include.  The overhead is minimal, and zero string parsing needed.&lt;br&gt;&lt;br&gt;Then we can do this:&lt;br&gt;&lt;br&gt;getUsers(_, _, $username);&lt;br&gt;&lt;br&gt;-or-&lt;br&gt;&lt;br&gt;getUsers(PAR(&#039;username&#039;, $username));&lt;br&gt;&lt;br&gt;I think our implementation is a little more correct (at the expense of being a little more annoying), but there is definitely some parallel thinking here.&lt;br&gt;&lt;br&gt;I wish people like @hylje would stop being snarky.  The world would be a better place.</description>
		<content:encoded><![CDATA[<p>This is similar to what we&#39;ve done, but we used different elbow-grease.  See &#8212; </p>
<p><a href="http://www.seoegghead.com/software/downloads/php-parameter-skipping-and-named-parameters.php" rel="nofollow"></a><a href="http://www.seoegghead.com/software/downloads/ph.." rel="nofollow">http://www.seoegghead.com/software/downloads/ph..</a>.</p>
<p>We hijack the parameter list via an include.  It&#39;s a hack, but it&#39;s elegant, and it&#39;s always the same cut-and-pasted include.  The overhead is minimal, and zero string parsing needed.</p>
<p>Then we can do this:</p>
<p>getUsers(_, _, $username);</p>
<p>-or-</p>
<p>getUsers(PAR(&#39;username&#39;, $username));</p>
<p>I think our implementation is a little more correct (at the expense of being a little more annoying), but there is definitely some parallel thinking here.</p>
<p>I wish people like @hylje would stop being snarky.  The world would be a better place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/comment-page-1/#comment-2471</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sun, 03 May 2009 02:33:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=227#comment-2471</guid>
		<description>The array solution makes code more difficult to read - this is more succint.</description>
		<content:encoded><![CDATA[<p>The array solution makes code more difficult to read &#8211; this is more succint.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iongion</title>
		<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/comment-page-1/#comment-2466</link>
		<dc:creator>iongion</dc:creator>
		<pubDate>Sat, 02 May 2009 23:57:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=227#comment-2466</guid>
		<description>Why wouldn&#039;t array solution just fit your needs ? just because you have to type in &quot;array&quot; construct ?

This is not python, it is PHP, get used to it having his own ways(most of them bad ways)</description>
		<content:encoded><![CDATA[<p>Why wouldn&#8217;t array solution just fit your needs ? just because you have to type in &#8220;array&#8221; construct ?</p>
<p>This is not python, it is PHP, get used to it having his own ways(most of them bad ways)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/comment-page-1/#comment-2124</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 22 Apr 2009 21:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=227#comment-2124</guid>
		<description>@david

Because PHP doesn&#039;t natively support true named parameter passing this is mostly a &quot;hack&quot;.

Also, because PHP is loosely typed and you can&#039;t specify that a certain method parameter only accept an Object, I can&#039;t think of any way to handle that special case.

I wouldn&#039;t suggest this solution be adopted for general programming in PHP however there are some specific cases where this can be very useful.  One of them would be in the creation of Rails like helper methods for a view (which is where I&#039;m using it now in my own projects).</description>
		<content:encoded><![CDATA[<p>@david</p>
<p>Because PHP doesn&#8217;t natively support true named parameter passing this is mostly a &#8220;hack&#8221;.</p>
<p>Also, because PHP is loosely typed and you can&#8217;t specify that a certain method parameter only accept an Object, I can&#8217;t think of any way to handle that special case.</p>
<p>I wouldn&#8217;t suggest this solution be adopted for general programming in PHP however there are some specific cases where this can be very useful.  One of them would be in the creation of Rails like helper methods for a view (which is where I&#8217;m using it now in my own projects).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david g.</title>
		<link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/comment-page-1/#comment-2123</link>
		<dc:creator>david g.</dc:creator>
		<pubDate>Wed, 22 Apr 2009 21:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=227#comment-2123</guid>
		<description>in the switch at line 64 -- how do I pass in parameters whose type are Object? It appears to be only testing for simple types (strings, bools, numbers ...) which are known.

how is this clearer than just making every function in your object have a signature such as:

function foo($opts=array()) { return $blah; }

yes, you get some default named parameter value handling from some boilerplate code ... but it appears you&#039;re limiting what kinds of parameters you are able to pass around ... imho this looks like over-engineering that&#039;ll lead to coding yourself into a corner.</description>
		<content:encoded><![CDATA[<p>in the switch at line 64 &#8212; how do I pass in parameters whose type are Object? It appears to be only testing for simple types (strings, bools, numbers &#8230;) which are known.</p>
<p>how is this clearer than just making every function in your object have a signature such as:</p>
<p>function foo($opts=array()) { return $blah; }</p>
<p>yes, you get some default named parameter value handling from some boilerplate code &#8230; but it appears you&#8217;re limiting what kinds of parameters you are able to pass around &#8230; imho this looks like over-engineering that&#8217;ll lead to coding yourself into a corner.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
