<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>kill the radio &#187; features</title>
	<atom:link href="http://blog.killtheradio.net/tag/features/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.killtheradio.net</link>
	<description>or die trying</description>
	<lastBuildDate>Thu, 15 Dec 2011 20:21:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP finally has anonymous functions??</title>
		<link>http://blog.killtheradio.net/technology/php-finally-has-anonymous-functions/</link>
		<comments>http://blog.killtheradio.net/technology/php-finally-has-anonymous-functions/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 18:30:37 +0000</pubDate>
		<dc:creator>Andrew Lyon</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.killtheradio.net/?p=679</guid>
		<description><![CDATA[Wow, I can&#8217;t believe I missed this&#8230;nobody seems to be talking about it at all. Ever since PHP 5.3, I can finally do non-generic callbacks. UPDATE: Check out this description of PHP lambdas (much better than what I&#8217;ve done in the following). function do_something($value) { // used &#62;= 2 times, but only in this function, [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, I can&#8217;t believe I missed this&#8230;nobody seems to be talking about it at all. Ever since PHP 5.3, <a href="http://php.net/manual/en/functions.anonymous.php">I can finally do non-generic callbacks</a>.</p>
<p>UPDATE: <a href="http://www.ibm.com/developerworks/opensource/library/os-php-5.3new2/index.html">Check out this description of PHP lambdas</a> (much better than what I&#8217;ve done in the following).</p>
<pre>function do_something($value)
{
    // used &gt;= 2 times, but only in this function, so no need for a global
    $local_function = function($value) { ... };

    // use our wonderful anonymous function
    $result = $local_function($value);
    ...
    // and again
    $result = $local_function($result);
    return $result;
}</pre>
<p>There&#8217;s also some other great stuff you can do:</p>
<pre>$favorite_songs = array(
    array('name' =&gt; 'hit me baby one more time', 'artist' =&gt; 'britney'),
    array('name' =&gt; 'genie in a bottle', 'artist' =&gt; 'xtina'),
    array('name' =&gt; 'last resort', 'artist' =&gt; 'papa roach')
);
$song_names = array_map(function($item) { return $item['name']; }, $favorite_songs);</pre>
<p>GnArLy bra. If PHP was 20 miles behind Lisp, it just caught up by about 30 feet. This has wonderful implications because there are a lot of functions that take a callback, and the only way to use them was to define a global function and send in an array() callback. Terrible. Inexcusable. Vomit-inducing.</p>
<p>Not only can you now use anonymous functions for things like array_map() and preg_replace_callback(), you can define your own functions that take functions as arguments:</p>
<pre>function do_something_binary($fn_success, $fn_failed)
{
    $success = ...
    if($success)
    {
        return $fn_success();
    }
    return $fn_failed();
}

do_something_binary(
    function() { echo "I successfully fucked a goat!"; },
    function() { echo "The goat got away..."; }
);</pre>
<p>Sure, you could just return $success and call whichever function you need after that, but this is just a simple example. It can be very useful to encapsulate code and send it somewhere, this is just a demonstration of the beautiful new world that just opened for PHP.</p>
<p>So drop your crap shared host (unless it has &gt;= 5.3.0), get a VPS, and start using this wonderful new feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.killtheradio.net/technology/php-finally-has-anonymous-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code section</title>
		<link>http://blog.killtheradio.net/updates/code-section/</link>
		<comments>http://blog.killtheradio.net/updates/code-section/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 00:46:33 +0000</pubDate>
		<dc:creator>Andrew Lyon</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[features]]></category>

		<guid isPermaLink="false">http://blog.killtheradio.net/?p=183</guid>
		<description><![CDATA[Holaaa. Added a code section on the main page that I plan to more more into. It&#8217;s got tag searching (intersection-based) for all two pieces of code posted (in case you can&#8217;t find one or the other) but there&#8217;s going to be more coming up, hopefully. So go check it out. All the code on [...]]]></description>
			<content:encoded><![CDATA[<p>Holaaa. Added a code section on the main page that I plan to more more into. It&#8217;s got tag searching (intersection-based) for all two pieces of code posted (in case you can&#8217;t find one or the other) but there&#8217;s going to be more coming up, hopefully.</p>
<p>So go check it out. All the code on there is free to use, distribute, sell, whatever you want. Just give me credit, or prepare yourself for hand-to-hand combat.</p>
<p>kkthxbai</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.killtheradio.net/updates/code-section/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

