<?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"
	>
<channel>
	<title>Comments on: Named Parameters Not Simple Enough</title>
	<atom:link href="http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/feed/" rel="self" type="application/rss+xml" />
	<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/</link>
	<description>Being read by one person since 2003</description>
	<pubDate>Sat, 22 Nov 2008 03:51:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Volomike</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-26775</link>
		<dc:creator>Volomike</dc:creator>
		<pubDate>Sat, 08 Nov 2008 05:45:04 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-26775</guid>
		<description>Here's my solution.

First, realize that you can easily make an object out of an array:

$oObject = (object) array('FirstName' =&#62; 'Volo', 'LastName' =&#62; 'Mike');

and so you can read and write this:

echo $oObject-&#62;LastName;
$oObject-&#62;FirstName = 'Hello';

Next, you can make your functions accept an object like so:

function MyFunction(&#38; $oObject) {
}

And you can also use 'return $oObject' to make a function return an Object with multiple parameters if you want.

So there you have it -- named parameters in an couple easy steps. No parsing necessary.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s my solution.</p>
<p>First, realize that you can easily make an object out of an array:</p>
<p>$oObject = (object) array(&#8217;FirstName&#8217; =&gt; &#8216;Volo&#8217;, &#8216;LastName&#8217; =&gt; &#8216;Mike&#8217;);</p>
<p>and so you can read and write this:</p>
<p>echo $oObject-&gt;LastName;<br />
$oObject-&gt;FirstName = &#8216;Hello&#8217;;</p>
<p>Next, you can make your functions accept an object like so:</p>
<p>function MyFunction(&amp; $oObject) {<br />
}</p>
<p>And you can also use &#8216;return $oObject&#8217; to make a function return an Object with multiple parameters if you want.</p>
<p>So there you have it &#8212; named parameters in an couple easy steps. No parsing necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomila</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-26773</link>
		<dc:creator>Tomila</dc:creator>
		<pubDate>Thu, 06 Nov 2008 03:32:40 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-26773</guid>
		<description>The author uvazhuha! Here's how to write blogs must! Everyone stands to learn, boys!</description>
		<content:encoded><![CDATA[<p>The author uvazhuha! Here&#8217;s how to write blogs must! Everyone stands to learn, boys!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim Bruning</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-24002</link>
		<dc:creator>Kim Bruning</dc:creator>
		<pubDate>Mon, 11 Feb 2008 11:04:39 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-24002</guid>
		<description>3 years late too.

And like, *argh*. The main reason I use python for as many projects as possible is because it has named parameters.

Compare:

Ship ship=new ship(200,100,50,50,100,150,120,true);

with the hypothetical:
Coordinates position=new Coordinates(x=200, y=100,z=50);
Color color=new Color(red=50, green=100, blue=150);
Ship ship=new ship(position, color, facing_angle=120, alive=true );


Which would you prefer?</description>
		<content:encoded><![CDATA[<p>3 years late too.</p>
<p>And like, *argh*. The main reason I use python for as many projects as possible is because it has named parameters.</p>
<p>Compare:</p>
<p>Ship ship=new ship(200,100,50,50,100,150,120,true);</p>
<p>with the hypothetical:<br />
Coordinates position=new Coordinates(x=200, y=100,z=50);<br />
Color color=new Color(red=50, green=100, blue=150);<br />
Ship ship=new ship(position, color, facing_angle=120, alive=true );</p>
<p>Which would you prefer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rtconner</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-23882</link>
		<dc:creator>rtconner</dc:creator>
		<pubDate>Fri, 08 Feb 2008 08:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-23882</guid>
		<description>sorry if i'm 3 years late.. but still no plans in php6 for named parameters as far as I can see. that is so sad. it would be an absolutely great feature to have.</description>
		<content:encoded><![CDATA[<p>sorry if i&#8217;m 3 years late.. but still no plans in php6 for named parameters as far as I can see. that is so sad. it would be an absolutely great feature to have.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Nobrega</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-102</link>
		<dc:creator>Julio Nobrega</dc:creator>
		<pubDate>Fri, 30 Dec 2005 07:11:21 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-102</guid>
		<description>Oooops... broken HTML... alternative here:

http://tinyurl.com/89v7c</description>
		<content:encoded><![CDATA[<p>Oooops&#8230; broken HTML&#8230; alternative here:</p>
<p><a href="http://tinyurl.com/89v7c" rel="nofollow">http://tinyurl.com/89v7c</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Nobrega</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-99</link>
		<dc:creator>Julio Nobrega</dc:creator>
		<pubDate>Fri, 30 Dec 2005 06:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-99</guid>
		<description>Thanks for the comment Adam!

There's a way to do what you asked, to mix default and named parameters, with a weirdness like $named-&#62;default_var($default_var), but anyway :) Works with PHP5 only... I hope your Wordpress is accepting code on comments, because here it goes:
&lt;pre&gt;
class named
{
    public function clean()
    {
        foreach ($this as $key =&#62; $value) {
            unset($this-&#62;$key);
        }
    }

    private function __call($method, $arguments)
    {
        if (isset($this-&#62;$method)) {
            return $this-&#62;$method;
        } else {
            return $arguments[0];
        }
    }
}

$named = new named();

function inputText($name, $maxlength = 5)
{
    global $named;

    $html = "maxlength($maxlength) . "\" ";

    $html .= " /&#62;\n";

    $named-&#62;clean();

    return $html;
}

echo inputText('input_name');

echo inputText('input_name', $named-&#62;maxlength = 10);

/*
Outputs:


*/
&lt;/pre&gt;
Actually that's a pretty sweet solution considering the circustances ;) You  can define functions with mandatory parameters, default, and optional (using isset($name-&#62;$argument) from my previous code).

__call(), from PHP5, does the magic here, otherwise every method needs to be declared on named, like function maxlength()...</description>
		<content:encoded><![CDATA[<p>Thanks for the comment Adam!</p>
<p>There&#8217;s a way to do what you asked, to mix default and named parameters, with a weirdness like $named-&gt;default_var($default_var), but anyway <img src='http://adam.404.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Works with PHP5 only&#8230; I hope your Wordpress is accepting code on comments, because here it goes:</p>
<pre>
class named
{
    public function clean()
    {
        foreach ($this as $key =&gt; $value) {
            unset($this-&gt;$key);
        }
    }

    private function __call($method, $arguments)
    {
        if (isset($this-&gt;$method)) {
            return $this-&gt;$method;
        } else {
            return $arguments[0];
        }
    }
}

$named = new named();

function inputText($name, $maxlength = 5)
{
    global $named;

    $html = &#8220;maxlength($maxlength) . &#8220;\&#8221; &#8220;;

    $html .= &#8221; /&gt;\n&#8221;;

    $named-&gt;clean();

    return $html;
}

echo inputText(&#8217;input_name&#8217;);

echo inputText(&#8217;input_name&#8217;, $named-&gt;maxlength = 10);

/*
Outputs:

*/
</pre>
<p>Actually that&#8217;s a pretty sweet solution considering the circustances <img src='http://adam.404.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> You  can define functions with mandatory parameters, default, and optional (using isset($name-&gt;$argument) from my previous code).</p>
<p>__call(), from PHP5, does the magic here, otherwise every method needs to be declared on named, like function maxlength()&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Nobrega</title>
		<link>http://adam.404.org/2005/12/03/named-parameters-not-simple-enough/#comment-96</link>
		<dc:creator>Julio Nobrega</dc:creator>
		<pubDate>Thu, 29 Dec 2005 17:01:34 +0000</pubDate>
		<guid isPermaLink="false">http://adam.404.org/?p=84#comment-96</guid>
		<description>Hi, I ended up here while googling for "php named parameters", to see if there was a way to use this feature.

Since there was no "official" way, and alternatives like using associative array and eval(), I decide to write my own :p

Tell me what you think...

http://tinyurl.com/apts7</description>
		<content:encoded><![CDATA[<p>Hi, I ended up here while googling for &#8220;php named parameters&#8221;, to see if there was a way to use this feature.</p>
<p>Since there was no &#8220;official&#8221; way, and alternatives like using associative array and eval(), I decide to write my own :p</p>
<p>Tell me what you think&#8230;</p>
<p><a href="http://tinyurl.com/apts7" rel="nofollow">http://tinyurl.com/apts7</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
