<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>I will not buy this blog, it is scratched!</title>
	<atom:link href="http://lanzkron.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lanzkron.wordpress.com</link>
	<description>Motti Lanzkron&#039;s seldom updated blog about programming, parenting and other things beginning with &#039;P&#039;</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:37:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lanzkron.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>I will not buy this blog, it is scratched!</title>
		<link>http://lanzkron.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lanzkron.wordpress.com/osd.xml" title="I will not buy this blog, it is scratched!" />
	<atom:link rel='hub' href='http://lanzkron.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A Turkey by any other name&#8230;</title>
		<link>http://lanzkron.wordpress.com/2012/01/17/a-turkey-by-any-other-name/</link>
		<comments>http://lanzkron.wordpress.com/2012/01/17/a-turkey-by-any-other-name/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 11:48:47 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=835</guid>
		<description><![CDATA[Recently we were discussing how the bird Turkey seems to be named after other countries, in Hebrew it&#8217;s an Indian chicken, in Portuguese it&#8217;s named after Peru and in Arabic it&#8217;s Ethiopian.  The fact that turkeys actually originate in North America didn&#8217;t seem to be taken into consideration (except by the Russians). When I stumbled across the List of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=835&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently we were discussing how the bird Turkey seems to be named after <em>other</em> countries, in <em>Hebrew</em> it&#8217;s an <strong>Indian</strong> chicken, in <span style="background-color:#ffffff;font-family:sans-serif;"><em>Portuguese</em> it&#8217;s named after </span><strong><span style="background-color:#ffffff;">Peru </span></strong>and in <em>Arabic</em> it&#8217;s <strong>Ethiopian</strong>.  The fact that turkeys actually originate in North America didn&#8217;t seem to be taken into consideration (except by the Russians).</p>
<p>When I stumbled across the<a href="http://en.wikipedia.org/wiki/List_of_names_for_the_Wild_Turkey"> List of names for the Wild Turkey</a> Wikipedia page I decided this called for a map.</p>
<p><a href="http://lanzkron.files.wordpress.com/2012/01/turkey-names-map.jpg"><img class="aligncenter size-full wp-image-887" title="Names for Turkeys" src="http://lanzkron.files.wordpress.com/2012/01/turkey-names-map.jpg?w=510&#038;h=256" alt="Names for Turkeys over the globe" width="510" height="256" /></a></p>
<p>The longest path I found involved 6 countries (5 links):</p>
<p style="padding-left:30px;">Bulgaria → Egypt → Greece → France → India → Peru</p>
<p style="padding-left:30px;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/835/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=835&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2012/01/17/a-turkey-by-any-other-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2012/01/turkey-names-map.jpg" medium="image">
			<media:title type="html">Names for Turkeys</media:title>
		</media:content>
	</item>
		<item>
		<title>Who has access to your private parts?</title>
		<link>http://lanzkron.wordpress.com/2011/12/17/who-has-access-to-your-private-parts/</link>
		<comments>http://lanzkron.wordpress.com/2011/12/17/who-has-access-to-your-private-parts/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 19:39:50 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=805</guid>
		<description><![CDATA[A famous quip says that C++ is the language in which friends have access to your private parts. But is it only friends? When writing an RAII object I was feeling a bit lazy (which as we know is a virtue) and was surprised to discover that a local class (a class defined in a function body) has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=805&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A famous quip says that C++ is the language in which <code style="display:inline;background:#fff;padding:0 1px;">friend</code>s have access to your private parts.</p>
<p>But is it only friends?</p>
<p>When writing an <a title="Resource Acquisition is Initialization" href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization">RAII</a> object I was feeling a bit lazy (which as we know <a href="http://c2.com/cgi/wiki?LazinessImpatienceHubris">is a virtue</a>) and was surprised to discover that a local class (a class defined in a function body) has access to its enclosing class&#8217;s private members.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">class</span> outer <span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">int</span> private_<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">public</span><span style="color:#e34adc;">:</span>
    outer<span style="color:#308080;">(</span><span style="color:#308080;">)</span> <span style="color:#406080;">:</span> private_<span style="color:#308080;">(</span><span style="color:#008c00;">0</span><span style="color:#308080;">)</span> <span style="color:#406080;">{</span><span style="color:#406080;">}</span>

    <span style="color:#200080;font-weight:bold;">void</span> print<span style="color:#308080;">(</span><span style="color:#308080;">)</span> <span style="color:#406080;">{</span>   <span style="color:#003060;">cout</span> <span style="color:#308080;">&lt;</span><span style="color:#308080;">&lt;</span> private_ <span style="color:#308080;">&lt;</span><span style="color:#308080;">&lt;</span> endl<span style="color:#406080;">;</span> <span style="color:#406080;">}</span>

    <span style="color:#200080;font-weight:bold;">void</span> foo<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">class</span> local <span style="color:#406080;">{</span> <span style="color:#595979;">// RAII object</span>
            outer<span style="color:#308080;">*</span> outer_<span style="color:#406080;">;</span>
<span style="color:#e34adc;">        </span><span style="color:#200080;font-weight:bold;">public</span><span style="color:#e34adc;">:</span>
            local<span style="color:#308080;">(</span>outer<span style="color:#308080;">*</span> p<span style="color:#308080;">)</span>
                <span style="color:#406080;">:</span> outer_<span style="color:#308080;">(</span>p<span style="color:#308080;">)</span>
            <span style="color:#406080;">{</span>
                outer_<span style="color:#308080;">-</span><span style="color:#308080;">&gt;</span>private_<span style="color:#308080;">+</span><span style="color:#308080;">+</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            <span style="color:#308080;">~</span>local<span style="color:#308080;">(</span><span style="color:#308080;">)</span> <span style="color:#406080;">{</span> outer_<span style="color:#308080;">-</span><span style="color:#308080;">&gt;</span>private_<span style="color:#308080;">-</span><span style="color:#308080;">-</span><span style="color:#406080;">;</span> <span style="color:#406080;">}</span>
        <span style="color:#406080;">}</span><span style="color:#406080;">;</span>

        print<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span><span style="color:#595979;"> // -&gt; 0</span>

        <span style="color:#406080;">{</span><span style="color:#595979;">// Scope for RAII object </span>

            local in<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
            print<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span><span style="color:#595979;"> // -&gt; 1</span>
        <span style="color:#406080;">}</span>

        print<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span><span style="color:#595979;"> // -&gt; 0</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span><span style="color:#406080;">;</span></pre>
<p>A quick look through the standard didn&#8217;t show where such behaviour is specified but it compiled with all the compilers I threw it at<sup><a id="local-fn1s" href="#local-fn1">[1]</a></sup>.</p>
<p>When I revealed this discovery to my cow-orkers they responded with an empathic &#8220;DUH!&#8221;  Oh well there  goes my C++ geek-cred  :o(</p>
<p>Allowing local classes access to private members makes a lot of sense on the language design front, after all if you can create a class in a method you should be able to do anything the method can do.  I just never thought of it before and apparently I&#8217;m not the only one.  When looking at C++11&#8242;s standard (well the final draft actually) I found the following in section 11 (<em>Member access control</em>):</p>
<blockquote><p>A member of a class can also access all the names to which the class has access. A local class of a member function may access the same names that the member function itself may access.</p></blockquote>
<p>Since this sentence does not appear in the original &#8217;98 standard I can only assume that greater minds than mine had also missed this point, at least at first.</p>
<p>Having classes which can access your private parts can be very useful, they can be used for temporarily changing state (as in the RAII class above) or they can be used as parameters to STL algorithms<sup><a id="local-fn2s" href="#local-fn2">[2]</a></sup>. The problem is that having a local class breaks the flow of the function and a nested class must be defined in the header so that something which is an implementation detail becomes globally visible.</p>
<p>But wait, the section in the standard had a footnote. <em>&#8220;Access permissions are thus transitive and cumulative to nested and local classes.&#8221;</em></p>
<p><em>Transitive</em>, that implies more than one level, this gave me an idea for a new(?) C++ pattern. I don&#8217;t know if I&#8217;m the first who thought of it and I doubt it&#8217;s very useful but here goes, I&#8217;m very proud to introduce the <strong>nested<sup>2</sup></strong> pattern.</p>
<p>For every class we can create a backdoor class that allows creation of quasi-friend classes. Then if the need arises we can add these quasi-friend classes in the .cpp file.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#595979;">// .h file</span>
<span style="color:#200080;font-weight:bold;">class</span> troy <span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">class</span> wooden_horse<span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">int</span> private_<span style="color:#406080;">;</span>
<span style="color:#200080;font-weight:bold;">public</span><span style="color:#e34adc;">:</span>
    troy<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">void</span> foo<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
<span style="color:#406080;">}</span><span style="color:#406080;">;</span>

<span style="color:#595979;">// .cpp file</span>
<span style="color:#200080;font-weight:bold;">class</span> troy<span style="color:#406080;">::</span>wooden_horse <span style="color:#406080;">{</span>
<span style="color:#200080;font-weight:bold;">public</span><span style="color:#e34adc;">:</span>
    <span style="color:#200080;font-weight:bold;">struct</span> odysseus <span style="color:#406080;">{</span>
        troy<span style="color:#308080;">*</span> t_<span style="color:#406080;">;</span>
        odysseus<span style="color:#308080;">(</span>troy<span style="color:#308080;">*</span> p<span style="color:#308080;">)</span> <span style="color:#406080;">:</span> t_<span style="color:#308080;">(</span>p<span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            t_<span style="color:#308080;">-</span><span style="color:#308080;">&gt;</span>private_<span style="color:#308080;">+</span><span style="color:#308080;">+</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>

        <span style="color:#308080;">~</span>odysseus<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
        <span style="color:#406080;">{</span>
            t_<span style="color:#308080;">-</span><span style="color:#308080;">&gt;</span>private_<span style="color:#308080;">-</span><span style="color:#308080;">-</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span><span style="color:#406080;">;</span>

    <span style="color:#595979;">// Add Greek warriors as needed</span>
<span style="color:#406080;">}</span><span style="color:#406080;">;</span>

troy<span style="color:#406080;">::</span>troy<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
    <span style="color:#406080;">:</span> private_<span style="color:#308080;">(</span><span style="color:#008c00;">41</span><span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
<span style="color:#406080;">}</span>

<span style="color:#200080;font-weight:bold;">void</span> troy<span style="color:#406080;">::</span>foo<span style="color:#308080;">(</span><span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    wooden_horse<span style="color:#406080;">::</span>odysseus odysseus<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#003060;">cout</span> <span style="color:#308080;">&lt;</span><span style="color:#308080;">&lt;</span> private_ <span style="color:#308080;">&lt;</span><span style="color:#308080;">&lt;</span> endl<span style="color:#406080;">;</span>
<span style="color:#406080;">}</span></pre>
<p>By making the backdoor class private we can be sure that the quasi-friend classes won&#8217;t be abused since nobody but our class will be able to create an object of this type.</p>
<hr />
<p><strong>Edit:</strong> Ever since I posted this I couldn&#8217;t sleep at night, I knew I would never forgive myself if I don&#8217;t to this:</p>
<blockquote>
<pre style="color:#d1d1d1;background-image:initial;background-attachment:initial;background-color:#000000;background-position:initial initial;background-repeat:initial initial;"><span style="color:#d2cd86;">:</span><span style="color:#d2cd86;">%</span>s<span style="color:#d2cd86;">/</span>troy<span style="color:#d2cd86;">/</span>french<span style="color:#d2cd86;">_</span>castle<span style="color:#d2cd86;">/</span>g
<span style="color:#d2cd86;">:</span><span style="color:#d2cd86;">%</span>s<span style="color:#d2cd86;">/</span>wooden<span style="color:#d2cd86;">_</span>horse<span style="color:#d2cd86;">/</span>large<span style="color:#d2cd86;">_</span>wooden<span style="color:#d2cd86;">_</span>badger<span style="color:#d2cd86;">/</span>g
<span style="color:#d2cd86;">:</span><span style="color:#d2cd86;">%</span>s<span style="color:#d2cd86;">/</span>odysseus<span style="color:#d2cd86;">/</span>bedemir<span style="color:#d2cd86;">/</span>g
<span style="color:#d2cd86;">:</span><span style="color:#d2cd86;">%</span>s<span style="color:#d2cd86;">/</span>Greek warriors<span style="color:#d2cd86;">/</span>Knights of the round table<span style="color:#d2cd86;">/</span>g
<span style="color:#d2cd86;">:</span>wq</pre>
</blockquote>
<hr />
<p><span id="local-fn1">[1]</span> VC8, VC10, gcc, clang and <a href="http://www.comeaucomputing.com/tryitout/">Comeu</a> (yes I am a bit obsessive, why do you ask?) <a title="back" href="#local-fn1s">↩</a></p>
<p><span id="local-fn2">[2]</span> Although this is less compelling since the introduction of <a href="http://en.wikipedia.org/wiki/C%2B%2B11#Lambda_functions_and_expressions">lambda expressions</a> in C++11. On second thought, since lambda functions are implemented as unnameable classes perhaps this is the reason for the change in the standard, to allow lambda functions the same access rights as the method that defined them. <a title="back" href="#local-fn2s">↩</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/805/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/805/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/805/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=805&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/12/17/who-has-access-to-your-private-parts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>
	</item>
		<item>
		<title>Did you pack that yourself?</title>
		<link>http://lanzkron.wordpress.com/2011/11/05/did-you-pack-that-yourself/</link>
		<comments>http://lanzkron.wordpress.com/2011/11/05/did-you-pack-that-yourself/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 17:01:05 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=802</guid>
		<description><![CDATA[A while ago I answered a stackoverflow question related to C++11&#8242;s variadic templates. I gave an example of one of the simplest variadic template functions imaginable: int maximum(int n) { return n; } template&#60;typename... Args&#62; int maximum(int n, Args... rest) { return max(n, maximum(rest...)); } A commenter asked if the ellipsis after Args and rest [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=802&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I answered a <a href="http://stackoverflow.com/questions/3634379/variadic-templates/3645307#3645307">stackoverflow question</a> related to C++11&#8242;s <a href="http://en.wikipedia.org/wiki/Variadic_template">variadic templates</a>. I gave an example of one of the simplest variadic template functions imaginable:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">int</span> maximum<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">int</span> n<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">return</span> n<span style="color:#406080;">;</span>
<span style="color:#406080;">}</span>

<span style="color:#200080;font-weight:bold;">template</span><span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">typename</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span> Args<span style="color:#406080;">&gt;</span>
<span style="color:#200080;font-weight:bold;">int</span> maximum<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">int</span> n<span style="color:#308080;">,</span> Args<span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span> rest<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">return</span> <span style="color:#003060;">max</span><span style="color:#308080;">(</span>n<span style="color:#308080;">,</span> maximum<span style="color:#308080;">(</span>rest<span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
<span style="color:#406080;">}</span></pre>
<p>A commenter asked if the ellipsis after <code style="display:inline;background:#fff;padding:0 1px;">Args</code> and <code style="display:inline;background:#fff;padding:0 1px;">rest</code> have any meaning or are they just <em>syntactic salt?</em></p>
<aside>To get the <a href="http://stackoverflow.com/q/7972263/3848">jargon straight</a> <code style="display:inline;background:#fff;padding:0 1px;">Args</code> is the variadic template <em>pattern</em>, <code style="display:inline;background:#fff;padding:0 1px;">rest</code> is the variadic parameter <em>pack</em> and the act of turning a template pack into parameters is called <em>pack expansion.</em><br />
</aside>
<p>This is a good question, the trailing ellipsis are used to expand the template parameter pack but since the only thing<sup><a id="variadic-fn1s" href="#variadic-fn1">[1]</a></sup> you can do with a parameter pack (or pattern) is expand it, why do we need the extra syntax?</p>
<p>I didn&#8217;t know the answer at first but after a bit of thought I believe this is the rationale:</p>
<p>When you unpack a template pack the compiler conceptually writes out the expanded pack, so if <code style="display:inline;background:#fff;padding:0 1px;">rest</code> is <code style="display:inline;background:#fff;padding:0 1px;">{ -2, 3, -4 }</code> the compiler turns <code style="display:inline;background:#fff;padding:0 1px;">maximum(rest...);</code> into <code style="display:inline;background:#fff;padding:0 1px;">maximum(-2, 3, -4);</code>  but you can do more, if you want to find the maximum of the absolute value of the numbers you could write <code style="display:inline;background:#fff;padding:0 1px;">maximum(abs(rest)...)</code> (note the ellipsis come <strong>after</strong> the close paren) which would expand to <code style="display:inline;background:#fff;padding:0 1px;">maximum(abs(-2), abs(3), abs(-4))</code>. The location of the ellipsis matters that&#8217;s why you have to write it explicitly.</p>
<p>This is also true with the template patterns.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">template</span> <span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">typename</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span> Pack<span style="color:#406080;">&gt;</span>
<span style="color:#200080;font-weight:bold;">struct</span> united <span style="color:#406080;">:</span> <span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#308080;">&lt;</span>Pack<span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">&gt;</span> <span style="color:#406080;">{</span>
<span style="color:#406080;">}</span><span style="color:#406080;">;</span>

united<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">const</span> <span style="color:#200080;font-weight:bold;">char</span><span style="color:#308080;">*</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">int</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span> we_stand<span style="color:#406080;">;</span>
<span style="color:#595979;">// we_stand is equivalent to being of type:</span>
<span style="color:#595979;">// struct united_XYZ : std::tuple&lt;const char*, int, bool&gt; {};</span>

<span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">const</span> <span style="color:#200080;font-weight:bold;">char</span><span style="color:#308080;">*</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">int</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span> <span style="color:#308080;">*</span>ok <span style="color:#308080;">=</span> <span style="color:#308080;">&amp;</span>we_stand<span style="color:#406080;">;</span>
<span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span> <span style="color:#308080;">*</span>error <span style="color:#308080;">=</span> <span style="color:#308080;">&amp;</span>we_stand<span style="color:#406080;">;</span> 

<span style="color:#200080;font-weight:bold;">template</span> <span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">typename</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span> Pack<span style="color:#406080;">&gt;</span>
<span style="color:#200080;font-weight:bold;">struct</span> divided <span style="color:#406080;">:</span> <span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#406080;">&lt;</span>Pack<span style="color:#406080;">&gt;</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span><span style="color:#308080;">.</span> <span style="color:#406080;">{</span>
<span style="color:#406080;">}</span><span style="color:#406080;">;</span>

divided<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">const</span> <span style="color:#200080;font-weight:bold;">char</span><span style="color:#308080;">*</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">int</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span> we_fall<span style="color:#406080;">;</span>
<span style="color:#595979;">// we_fall is equivalent to being of type:</span>
<span style="color:#595979;">// struct divided_XYZ : std::tuple&lt;const char*&gt;, std::tuple&lt;int&gt;, std::tuple&lt;bool&gt; {};</span>

<span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span><span style="color:#308080;">*</span>ok <span style="color:#308080;">=</span><span style="color:#308080;">&amp;</span>we_fall<span style="color:#406080;">;</span>
<span style="color:#0066ee;">std</span><span style="color:#406080;">::</span>tuple<span style="color:#406080;">&lt;</span><span style="color:#200080;font-weight:bold;">const</span> <span style="color:#200080;font-weight:bold;">char</span><span style="color:#308080;">*</span><span style="color:#308080;">,</span><span style="color:#200080;font-weight:bold;">int</span><span style="color:#308080;">,</span><span style="color:#200080;font-weight:bold;">bool</span><span style="color:#406080;">&gt;</span><span style="color:#308080;">*</span>error <span style="color:#308080;">=</span><span style="color:#308080;">&amp;</span>we_fall<span style="color:#406080;">;</span></pre>
<div style="border:1px solid #e6db55;width:80%;text-align:center;background-color:#ffffe0;">This post scheduled to appear on my 10th wedding anniversary</div>
<hr />
<p><span id="variadic-fn1"><br />
[1] And call <a href="http://en.wikipedia.org/wiki/Sizeof#sizeof..._and_variadic_template_packs">sizeof&#8230;</a> on it but that&#8217;s just nitpicking. <a title="back" href="#variadic-fn1s">↩</a></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/802/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/802/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/802/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=802&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/11/05/did-you-pack-that-yourself/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>
	</item>
		<item>
		<title>Give me some credit!</title>
		<link>http://lanzkron.wordpress.com/2011/10/23/give-me-some-credit/</link>
		<comments>http://lanzkron.wordpress.com/2011/10/23/give-me-some-credit/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 20:12:22 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[musing]]></category>
		<category><![CDATA[credit card]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=799</guid>
		<description><![CDATA[I&#8217;ve been trying to keep to a minimum of one post a month but am a bit short of ideas. In my desperation I&#8217;ll take some liberties with the mandate of this blog and talk about something pertaining to payment (even though my previous post regarding financial issues wasn&#8217;t such a big hit.) This must [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=799&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to keep to a minimum of one post a month but am a bit short of ideas. In my desperation I&#8217;ll take some liberties with the mandate of this blog and talk about something pertaining to <strong>p</strong>ayment (even though my <a title="Irrationality check" href="http://lanzkron.wordpress.com/2009/11/25/irrationality-check/">previous post regarding financial issues</a> wasn&#8217;t such a big hit.)</p>
<p>This must have been around 15 years ago, before I had an international credit card, I wanted to pay for some small purchase with my credit card when the cashier asked to see a photo ID (this is unusual in this neck of the woods.)  I pulled out my ID and she said <em>&#8220;The credit card says Motti Lanzkron but the ID says Mordechai Lanzkron.&#8221;</em>  I told her, what every native Israeli knows, (she was an immigrant) that Motti is short for Mordechai just as Bill is short for William, this took some convincing but she conceded the point. She then looked at the back of the credit card <em>&#8220;this isn&#8217;t signed, you need to sign the back.&#8221;</em>  I told her it <strong>was</strong> signed although a bit faded but she insisted so I re-signed the back (thinking inwardly how pointless this was.)</p>
<p>At this point the cashier looked at the back of the credit card and at the signed receipt and said <em>&#8220;the signatures aren&#8217;t the same.&#8221;</em> I was sure she was joking but that was not the case. After pointing out that she had just witnessed me pen <em>both</em> signatures I finally managed to finalize the transaction.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/799/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/799/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/799/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=799&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/10/23/give-me-some-credit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>
	</item>
		<item>
		<title>The worst acronym ever: SCARY iterators</title>
		<link>http://lanzkron.wordpress.com/2011/09/16/the-worst-acronym-ever-scary-iterators/</link>
		<comments>http://lanzkron.wordpress.com/2011/09/16/the-worst-acronym-ever-scary-iterators/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 09:00:12 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[acronyms]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=748</guid>
		<description><![CDATA[A couple of years ago there was a question in stackoverflow about the &#8220;Best IT/Programming/Technology related Acronym&#8221;. Tongue in cheek  I suggested I18N  (which is I followed by 18 letters followed by N). Yesterday I discovered the worst acronym when reading about what&#8217;s new in VC11, apparently Visual C++ now supports SCARY iterators. The link [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=748&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago there was a question in stackoverflow about the <em>&#8220;Best IT/Programming/Technology related Acronym&#8221;</em>. Tongue in cheek <a href="http://stackoverflow.com/questions/131729/best-it-programming-technology-related-acronym/132253#132253"> I suggested I18N</a>  (which is <em><strong>I</strong></em> followed by 18 letters followed by <em><strong>N</strong></em>).</p>
<p>Yesterday I discovered the <strong>worst</strong> acronym when reading about what&#8217;s <a href="http://msdn.microsoft.com/it-it/library/hh409293%28v=VS.110%29.aspx">new in VC11</a>, apparently Visual C++ now supports <em>SCARY iterators</em>. The <a href="http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2009/n2980.pdf">link explaining SCARY iterators</a> had this to say:</p>
<blockquote><p>N2911 explains that the acronym <strong>SCARY</strong> “describes assignments and initializations that are <strong>S</strong>eemingly erroneous (<strong>C</strong>onstrained by conflicting generic parameters), but <strong>A</strong>ctually work with the <strong>R</strong>ight implementation (unconstrained b<strong>Y</strong> the conflict due to minimized dependencies).”</p></blockquote>
<p>On the reddit  thread <a href="http://www.reddit.com/r/programming/comments/kgaop/worst_acronym_ever_scary_iterators_pdf/c2k0rqz">feembly said</a> the reason was probably because <em>&#8220;SECBCGPBAWWTRIUBTCDTMD just didn&#8217;t have the same ring&#8221;</em> which I took as proof that he isn&#8217;t Welsh. If I remember correctly my grandmother is from a small town near Secbcgpbawwtriubtcdtmd.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/748/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=748&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/09/16/the-worst-acronym-ever-scary-iterators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>
	</item>
		<item>
		<title>On the Complexities of Preparing Dinner</title>
		<link>http://lanzkron.wordpress.com/2011/08/21/on-the-complexities-of-preparing-dinner/</link>
		<comments>http://lanzkron.wordpress.com/2011/08/21/on-the-complexities-of-preparing-dinner/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 19:07:13 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[cooking]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[geek parenting]]></category>
		<category><![CDATA[parenting]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=683</guid>
		<description><![CDATA[During a coffee break I mentioned that &#8220;even though the kids prefer schnitzel I&#8217;d rather prepare baked chicken&#8221; When asked why I explained that &#8220;Chicken is O(1) and schnitzel is O(N)&#8220;. This is a case in which the joy of using jargon colloquially overrides strict correctness. Obviously making chicken isn&#8217;t O(1) even if you do  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=683&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>During a coffee break I mentioned that <em>&#8220;even though the kids prefer <a href="http://en.wikipedia.org/wiki/Schnitzel#Israel">schnitzel</a> I&#8217;d rather prepare baked chicken&#8221;</em></p>
<p>When asked why I explained that <em>&#8220;Chicken is </em><code style="border:none;display:inline;background:#fff;padding:0 1px;">O(1)</code><em> and schnitzel is </em><code style="border:none;display:inline;background:#fff;padding:0 1px;">O(N)</code><em>&#8220;. </em></p>
<p>This is a case in which the joy of using jargon colloquially overrides strict correctness. Obviously making chicken isn&#8217;t <code style="border:none;display:inline;background:none repeat scroll 0 0 #ffffff;padding:0 1px;">O(1)</code> even if you <em>do</em>  have an infinitely large oven.</p>
<div id="attachment_737" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.gas-grill-review.com/bbq-chicken-recipes.html"><img class="size-full wp-image-737" title="Chicken in the oven" src="http://lanzkron.files.wordpress.com/2011/06/chicken-oven.gif?w=510" alt=""   /></a><p class="wp-caption-text">Image stolen from gas-grill-review.com</p></div>
<p>Then again the complexity of finding an element in an unsorted sequence isn&#8217;t really <code style="border:none;display:inline;background:#fff;padding:0 1px;">O(N)</code> either, it&#8217;s <code style="border:none;display:inline;background:#fff;padding:0 1px;">O(N * Max(Cmp(a, b)))</code>. Comparing objects can <em>often</em> be considered <code style="border:none;display:inline;background:#fff;padding:0 1px;">O(1)</code>  (e.g. 32 bit integers) but if you want to compare books by the number of the times the letter <span style="color:#000080;"><strong><em>e </em></strong></span>show up in them, well then, comparing <em><strong>War and Peace</strong></em> to <em><strong>Les Misérables</strong></em> is far from constant speed (you could use <strong><em><a href="http://en.wikipedia.org/wiki/A_Void">A Void</a></em></strong> as the null book&lt;/aside&gt;)</p>
<p>The <strong>real</strong><sup><a id="dinner-fn1s" href="#dinner-fn1">[1]</a></sup> reasons I prefer making chicken to schnitzel are twofold.</p>
<ol>
<li>The constants are much bigger for schnitzel</li>
<li>Schnitzel making is synchronous while baking chicken is asynchronous</li>
</ol>
<p>And don&#8217;t get me started about the <del>space</del> dirty dishes complexity.</p>
<hr />
<ol>
<li><span id="dinner-fn1">Of course how healthy the food is doesn&#8217;t count as a consideration, we are geeks here after all.</span> <a title="back" href="#dinner-fn1s">↩</a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/683/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=683&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/08/21/on-the-complexities-of-preparing-dinner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/06/chicken-oven.gif" medium="image">
			<media:title type="html">Chicken in the oven</media:title>
		</media:content>
	</item>
		<item>
		<title>Formal parameters and the arguments object in JavaScript</title>
		<link>http://lanzkron.wordpress.com/2011/07/24/named-args-and-the-arguments-object-in-javascript/</link>
		<comments>http://lanzkron.wordpress.com/2011/07/24/named-args-and-the-arguments-object-in-javascript/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 18:22:41 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=744</guid>
		<description><![CDATA[Say you&#8217;re writing a function which takes a function name as an argument and passes the rest of its arguments to the named function. Your unit test for such a function may look like this: assertEquals('add', 5, calculate('add', 3, 2)); assertEquals('mul', 6, calculate('mul', 3, 2)); We would like to splice off the first element and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=744&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;re writing a function which takes a function name as an argument and passes the rest of its arguments to the named function. Your unit test for such a function may look like this:</p>
<pre style="color:#000020;background:none repeat scroll 0 0 #f6f8ff;padding-left:30px;">assertEquals<span style="color:#308080;">(</span><span style="color:#1060b6;">'add'</span><span style="color:#308080;">,</span> <span style="color:#008c00;">5</span><span style="color:#308080;">,</span> calculate<span style="color:#308080;">(</span><span style="color:#1060b6;">'add'</span><span style="color:#308080;">,</span> <span style="color:#008c00;">3</span><span style="color:#308080;">,</span> <span style="color:#008c00;">2</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
assertEquals<span style="color:#308080;">(</span><span style="color:#1060b6;">'mul'</span><span style="color:#308080;">,</span> <span style="color:#008c00;">6</span><span style="color:#308080;">,</span> calculate<span style="color:#308080;">(</span><span style="color:#1060b6;">'mul'</span><span style="color:#308080;">,</span> <span style="color:#008c00;">3</span><span style="color:#308080;">,</span> <span style="color:#008c00;">2</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span></pre>
<p>We would like to <code style="display:inline;background:#fff;border:0;padding:0 1px;"><a href="http://www.w3schools.com/jsref/jsref_splice.asp">splice</a></code> off the first element and pass the rest to another function but since <code style="display:inline;background:#fff;border:0;padding:0 1px;"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments">arguments</a></code> isn&#8217;t a real Array it doesn&#8217;t support the <code style="display:inline;background:#fff;border:0;padding:0 1px;">splice</code> method. Never mind, that&#8217;s easily treated by calling <code style="display:inline;background:#fff;border:0;padding:0 1px;">splice</code> with <code style="display:inline;background:#fff;border:0;padding:0 1px;">arguments</code> as <code style="display:inline;background:#fff;border:0;padding:0 1px;">this</code>.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">function</span> calculate<span style="color:#308080;">(</span>operation<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    <span style="color:#595979;">// Remove `operation' from arguments leaving only `a' and `b'</span>
    <span style="color:#007d45;">Array</span><span style="color:#308080;">.</span><span style="color:#007d45;">prototype</span><span style="color:#308080;">.</span>splice<span style="color:#308080;">.</span>call<span style="color:#308080;">(</span><span style="color:#007d45;">arguments</span><span style="color:#308080;">,</span> <span style="color:#008c00;">0</span><span style="color:#308080;">,</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> funcs <span style="color:#308080;">=</span> <span style="color:#406080;">{</span>
        add<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">+</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span><span style="color:#308080;">,</span>
        mul<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">*</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
    <span style="color:#200080;font-weight:bold;">return</span> funcs<span style="color:#308080;">[</span>operation<span style="color:#308080;">]</span><span style="color:#308080;">.</span>apply<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">,</span> <span style="color:#007d45;">arguments</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
<span style="color:#406080;">}</span></pre>
<p>So why are we getting an <span style="color:#ff0000;">Uncaught TypeError: Cannot call method &#8216;apply&#8217; of undefined<span style="color:#000000;">? Looking at things in Chrome&#8217;s debugger everything looks OK. <code style="display:inline;background:#fff;border:0;padding:0 1px;">operation</code> is &#8220;add&#8221; and <code style="display:inline;background:#fff;border:0;padding:0 1px;">funcs[operation]</code> is a function.</span></span></p>
<p><a href="http://lanzkron.files.wordpress.com/2011/07/named-arguments.jpg"><img class="aligncenter size-full wp-image-755" title="Named arguments in Chrome developer tools" src="http://lanzkron.files.wordpress.com/2011/07/named-arguments.jpg?w=510&#038;h=261" alt="View in Chrome developer tools" width="510" height="261" /></a><br />
It dawned on me that the debugger is lying (Firebug and IE&#8217;s debugger don&#8217;t have this problem), <code style="display:inline;background:#fff;border:0;padding:0 1px;">splice</code> removed the first parameter from <code style="display:inline;background:#fff;border:0;padding:0 1px;">arguments</code> and now the value of <strong>operation</strong> is <code style="display:inline;background:#fff;border:0;padding:0 1px;">3</code>. How come 3? Well operation was the first parameter and the first element in <code style="display:inline;background:#fff;border:0;padding:0 1px;">arguments</code> is now 3, it&#8217;s obvious really(?).</p>
<p>Now I picked up JavaScript on my own (as I assume many do) so I&#8217;m no expert and this took me by surprise (it&#8217;s probably not trivial even for <em>real</em> JavaScript developers if Chrome&#8217;s debugger has <a title="Chrome defect" href="http://code.google.com/p/chromium/issues/detail?id=88890">this defect</a>).</p>
<p>After meditating about the facts it makes sense that formal parameters and the elements in the <code style="display:inline;background:none repeat scroll 0 0 #ffffff;border:0 none;padding:0 1px;">arguments</code> object are aliases so that if you do <code style="display:inline;background:none repeat scroll 0 0 #ffffff;border:0 none;padding:0 1px;">arguments[2]++</code> the formal parameter  <strong>&#8216;b&#8217;</strong> changes too but this behaviour means that that these references are more like Perl&#8217;s much vilified <a href="http://perldoc.perl.org/perlref.html#Symbolic-references">symbolic references</a> than most languages&#8217; references. This means that using a formal parameter in JavaScript is semantically equivalent to indexing into the <code style="display:inline;background:none repeat scroll 0 0 #ffffff;border:0 none;padding:0 1px;">arguments</code> object, writing  <strong>operation</strong> in (this example) is just syntactic sugar for <code style="display:inline;background:none repeat scroll 0 0 #ffffff;border:0 none;padding:0 1px;">arguments[0]</code>. If you want to remove an argument from the <code style="display:inline;background:none repeat scroll 0 0 #ffffff;border:0 none;padding:0 1px;">arguments</code> object and still used the named parameter you must first cache the value in a separate variable.</p>
<p>Here&#8217;s the fixed version of calculate:</p>
<pre style="color:#000020;background:none repeat scroll 0 0 #f6f8ff;"><span style="color:#200080;font-weight:bold;">function</span> calculate<span style="color:#308080;">(</span>operation<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    <strong><span style="background-color:yellow;"> <span style="color:#200080;font-weight:bold;">var</span> op <span style="color:#308080;">=</span> operation<span style="color:#406080;">;</span> <span style="color:#595979;">// Save value of `operation'</span></span></strong>
    <span style="color:#595979;">// Remove `operation' from arguments leaving only `a' and `b'</span>
    <span style="color:#007d45;">Array</span><span style="color:#308080;">.</span><span style="color:#007d45;">prototype</span><span style="color:#308080;">.</span>splice<span style="color:#308080;">.</span>call<span style="color:#308080;">(</span><span style="color:#007d45;">arguments</span><span style="color:#308080;">,</span> <span style="color:#008c00;">0</span><span style="color:#308080;">,</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> funcs <span style="color:#308080;">=</span> <span style="color:#406080;">{</span>
        add<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">+</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span><span style="color:#308080;">,</span>
        mul<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">*</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
    <span style="color:#200080;font-weight:bold;">return</span> funcs<span style="color:#308080;">[</span>op<span style="color:#308080;">]</span><span style="color:#308080;">.</span>apply<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">,</span> <span style="color:#007d45;">arguments</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
<span style="color:#406080;">}</span></pre>
<hr />
<p><strong>Edit:</strong> as <em>strager</em> said in the <a href="http://www.reddit.com/r/javascript/comments/k16lx/formal_parameters_and_the_arguments_object_in/">reddit thread</a>:</p>
<blockquote><p>Takeaway:<br />
Do not modify the <code style="display:inline;background:#fff;border:0;padding:0 1px;">arguments</code> object.<br />
<strong>Ever.</strong></p></blockquote>
<p>Now that I&#8217;m older and slightly less ignorant I think this would be a better solution:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">function</span> calculate<span style="color:#308080;">(</span>operation<span style="color:#308080;">)</span>
<span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">var</span> funcs <span style="color:#308080;">=</span> <span style="color:#406080;">{</span>
        add<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">+</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span><span style="color:#308080;">,</span>
        mul<span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>a<span style="color:#308080;">,</span> b<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#200080;font-weight:bold;">return</span> a <span style="color:#308080;">*</span> b<span style="color:#406080;">;</span> <span style="color:#406080;">}</span>
    <span style="color:#406080;">}</span>
    <span style="color:#200080;font-weight:bold;">return</span> funcs<span style="color:#308080;">[</span>operation<span style="color:#308080;">]</span><span style="color:#308080;">.</span>apply<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">,</span>
                       <span style="color:#007d45;">Array</span><span style="color:#308080;">.</span><span style="color:#007d45;">prototype</span><span style="color:#308080;">.</span><span style="color:#200080;font-weight:bold;">slice</span><span style="color:#308080;">.</span>call<span style="color:#308080;">(</span><span style="color:#007d45;">arguments</span><span style="color:#308080;">,</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
<span style="color:#406080;">}</span></pre>
<hr />
<p><strong>Edit January 2012:</strong> The Chrome defect has been fixed (verified on Chrome 16).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/744/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=744&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/07/24/named-args-and-the-arguments-object-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/07/named-arguments.jpg" medium="image">
			<media:title type="html">Named arguments in Chrome developer tools</media:title>
		</media:content>
	</item>
		<item>
		<title>timeoutSort</title>
		<link>http://lanzkron.wordpress.com/2011/06/19/timeoutsort/</link>
		<comments>http://lanzkron.wordpress.com/2011/06/19/timeoutsort/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 19:29:58 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[humour]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=709</guid>
		<description><![CDATA[A recent post in 4chan introduced Sleep Sort. The reddit thread that ensued ported it to many languages (from the original bash) but I didn&#8217;t see anyone port it to JavaScript yet. So without further ado here&#8217;s my port to JavaScript called timeoutSort Array.prototype.timeoutSort = function(f) { this.forEach(function(n) { setTimeout(function() { f(n) }, 5*n) }) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=709&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A recent post in 4chan introduced <a href="http://dis.4chan.org/read/prog/1295544154">Sleep Sort</a>. The <a href="http://www.reddit.com/r/programming/comments/i0dcx/4chan_sleep_sort/">reddit thread</a> that ensued ported it to many languages (from the original bash) but I didn&#8217;t see anyone port it to JavaScript yet. So without further ado here&#8217;s my port to JavaScript called <strong>timeoutSort</strong></p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#007d45;">Array</span><span style="color:#308080;">.</span><span style="color:#007d45;">prototype</span><span style="color:#308080;">.</span>timeoutSort <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>f<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">this</span><span style="color:#308080;">.</span>forEach<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>n<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
        setTimeout<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span><span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
            f<span style="color:#308080;">(</span>n<span style="color:#308080;">)</span>
        <span style="color:#406080;">}</span><span style="color:#308080;">,</span> <span style="color:#008c00;">5</span><span style="color:#308080;">*</span>n<span style="color:#308080;">)</span>
    <span style="color:#406080;">}</span><span style="color:#308080;">)</span>
<span style="color:#406080;">}</span></pre>
<p>It can be used thus:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">[</span><span style="color:#008c00;">1</span><span style="color:#308080;">,</span><span style="color:#008c00;">9</span><span style="color:#308080;">,</span><span style="color:#008c00;">8</span><span style="color:#308080;">,</span><span style="color:#008c00;">7</span><span style="color:#308080;">,</span><span style="color:#008c00;">6</span><span style="color:#308080;">,</span><span style="color:#008c00;">5</span><span style="color:#308080;">,</span><span style="color:#008c00;">4</span><span style="color:#308080;">,</span><span style="color:#008c00;">3</span><span style="color:#308080;">,</span><span style="color:#008c00;">2</span><span style="color:#308080;">,</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">.</span>timeoutSort<span style="color:#308080;">(</span>alert<span style="color:#308080;">)</span></pre>
<p>Or thus:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">[</span><span style="color:#008c00;">1</span><span style="color:#308080;">,</span><span style="color:#008c00;">6</span><span style="color:#308080;">,</span><span style="color:#008c00;">4</span><span style="color:#308080;">,</span><span style="color:#008c00;">3</span><span style="color:#308080;">,</span><span style="color:#008c00;">5</span><span style="color:#308080;">,</span><span style="color:#008c00;">2</span><span style="color:#308080;">,</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">.</span>timeoutSort<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">function</span><span style="color:#308080;">(</span>n<span style="color:#308080;">)</span><span style="color:#406080;">{</span> document<span style="color:#308080;">.</span>write<span style="color:#308080;">(</span>n<span style="color:#308080;">+'</span><span style="color:#1060b6;">&lt;br&gt;'</span><span style="color:#308080;">)</span><span style="color:#406080;">}</span><span style="color:#308080;">)</span></pre>
<p>Share and enjoy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/709/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=709&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/06/19/timeoutsort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>
	</item>
		<item>
		<title>Pita Burger</title>
		<link>http://lanzkron.wordpress.com/2011/05/10/pita-burger/</link>
		<comments>http://lanzkron.wordpress.com/2011/05/10/pita-burger/#comments</comments>
		<pubDate>Tue, 10 May 2011 05:00:05 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[cooking]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=527</guid>
		<description><![CDATA[Today is Yom Ha&#8217;atzmaut, Israel&#8217;s independence day. In this day it&#8217;s traditional to have a cook-out during which many  pitas are spread with hummus and stuffed with meat, salad and chips. During last year&#8217;s celebrations I made a great discovery which will change the course of human history! A half defrosted hamburger split down the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=527&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today is <a href="http://en.wikipedia.org/wiki/Yom_Ha%27atzmaut">Yom Ha&#8217;atzmaut</a>, Israel&#8217;s independence day.</p>
<p>In this day it&#8217;s traditional to have a cook-out during which many  <a href="http://en.wikipedia.org/wiki/Pita">pita</a>s are spread with hummus and stuffed with meat, salad and chips.</p>
<p>During last year&#8217;s celebrations I made a great discovery which will change the course of human history! A half defrosted hamburger split down the middle on the grill presenting a void just waiting to be filled.</p>
<p>So without further ado and in keeping with this blog&#8217;s mandate of dealing with things that begin with the letter <strong><em>P</em></strong>, I&#8217;m proud to introduce the <strong>Pita-Burger!</strong></p>
<div id="attachment_702" class="wp-caption aligncenter" style="width: 520px"><a href="http://lanzkron.files.wordpress.com/2010/10/pitaburger.jpg"><img class="size-full wp-image-702 " title="pitaburger" src="http://lanzkron.files.wordpress.com/2011/05/pitaburger-small.jpg?w=510&#038;h=455" alt="Pita-Burger" width="510" height="455" /></a><p class="wp-caption-text">The world&#039;s first(?) Pita-Burger</p></div>
<p><strong><br />
</strong></p>
<p>This invention allows saving that resource which is always most scarce during barbecues, stomach real-estate, by leaving the pita out of the picture.</p>
<p>I was going to patent this stroke of genius and retire on my millions but unfortunately a friend of mine (<acronym title="Never Known As">NKA</acronym><em> The Dude</em>) pointed out that there was <a title="KFC Double Down" href="http://www.npr.org/blogs/waitwait/2010/04/kfc_double_down_live_blog.html">prior art</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/527/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=527&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/05/10/pita-burger/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/05/pitaburger-small.jpg" medium="image">
			<media:title type="html">pitaburger</media:title>
		</media:content>
	</item>
		<item>
		<title>Meaningless Benchmark Redux</title>
		<link>http://lanzkron.wordpress.com/2011/03/27/meaningless-benchmark-redux/</link>
		<comments>http://lanzkron.wordpress.com/2011/03/27/meaningless-benchmark-redux/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 17:26:18 +0000</pubDate>
		<dc:creator>Motti Lanzkron</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://lanzkron.wordpress.com/?p=678</guid>
		<description><![CDATA[A year ago I wrote a post called Yet Another Meaningless JavaScript Benchmark, in which I examined how different browsers behave in regards to an atypical JavaScript program (hence the meaningless part of the title). The last thing I expected was for someone to actually use this as  part of a benchmark suite. Since I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=678&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://lanzkron.files.wordpress.com/2011/03/old.png"><br />
</a>A year ago I wrote a post called <a title="Yet Another Meaningless JavaScript Benchmark" href="http://lanzkron.wordpress.com/2010/01/18/yet-another-meaningless-javascript-benchmark/"><em>Yet Another Meaningless JavaScript Benchmark</em></a>, in which I examined how different browsers behave in regards to an atypical JavaScript program (hence the <em>meaningless</em> part of the title). The last thing I expected was for someone to actually use this as  part of a <a href="http://www.charged.co.za/2010/03/25/betanews-relative-performance-index-for-browsers-3-0-how-it-works-and-why">benchmark suite</a>.</p>
<p>Since I published the post both IE and Firefox have released a new major version (and Chrome has released 7 major versions, but <a title="The day the version died" href="http://lanzkron.wordpress.com/2010/11/15/the-day-the-version-died/">who&#8217;s counting</a>?) so I guess now is as good a time as any to see how the new versions fare for the same test. Just re-running the test is rather boring so I&#8217;ve added two additional sections to this post in which I experiment with some of HTML5&#8242;s features.</p>
<ol>
<li>Using the canvas tag to create a visualization of a <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz orbit</a> <sub><a href="#hCanvas">[Jump there]</a></sub></li>
<li>Use <a href="http://www.whatwg.org/specs/web-workers/current-work/">Web Worker threads</a> in order to solve the same problem <sub><a href="#hThreads">[Jump there]</a></sub></li>
</ol>
<p>I should note that I&#8217;m <strong>not</strong> a web developer, I&#8217;m just playing around with HTML5 (and blogging) so if you <em>are </em>a web developer some of this may seem obvious. If you&#8217;re <em>not</em> a web developer you probably don&#8217;t much care about HTML5 so I&#8217;m not really sure who the audience of this post is&#8230;</p>
<p>All the code is available to <a href="http://lanzkron.co.cc/euler14.html">play with right here</a>.</p>
<h2>Rematch!</h2>
<p>When I originally run this test with IE8 Firefox 3.5 and Chrome 3 (yes 3) I got the following results:</p>
<p><a href="http://lanzkron.files.wordpress.com/2011/03/old.png"><img class="aligncenter size-full wp-image-686" title="Old versions" src="http://lanzkron.files.wordpress.com/2011/03/old.png?w=510&#038;h=312" alt="" width="510" height="312" /></a></p>
<p>Re-running the same test now gives very different results. Again I&#8217;m using the latest released versions of the browsers, IE9, Firefox 4 and Chrome 10 (on the same computer).</p>
<p><a href="http://lanzkron.files.wordpress.com/2011/03/current.png"><img class="aligncenter size-full wp-image-687" title="Current versions" src="http://lanzkron.files.wordpress.com/2011/03/current.png?w=510&#038;h=315" alt="" width="510" height="315" /></a>The first thing we can see is that the playing field has been levelled, IE is no longer pulling the Y axis into the triple digits, in fact it&#8217;s planted firmly in the single digits. Chrome is unique in taking more time to perform the optimized version in <strong>more</strong> time than it did 7 versions ago (I should reiterate that this <em>benchmark</em> is highly specialized which means it&#8217;s not worth optimizing for and Chrome may still out perform the other browsers in real-life scenarios).</p>
<p>Well now we&#8217;ve got that behind us, lets look at some HTML5 features</p>
<h2 id="hCanvas">Canvas</h2>
<p>The <a href="http://en.wikipedia.org/wiki/Canvas_element">canvas</a> element gives us the opportunity to visualize what a Collatz Orbit looks like, here&#8217;s the orbit for 87:</p>
<p><a href="http://lanzkron.files.wordpress.com/2011/03/canvas.png"><img class="aligncenter size-full wp-image-688" title="Orbit of Collatz 87" src="http://lanzkron.files.wordpress.com/2011/03/canvas.png?w=510&#038;h=341" alt="" width="510" height="341" /></a>The black dot is the starting point, odd numbers go to <strong>3*n+1 </strong>(in red) and even numbers go to <strong>n/2</strong> (in green), the blue dot marks where the orbit has reached 1.</p>
<p>The code for drawing the orbit is available <a href="http://lanzkron.co.cc/draw_collatz.js">here</a>, I won&#8217;t go into it since it&#8217;s pretty trivial. All I want to add on the subject is that I calculate the whole orbit in advance so that I know how big the canvas is going to be, since it can get to be quite big a lot of the drawing may take place off screen. The orbit is drawn step by step in order to give a feeling on what&#8217;s going on (you can configure the how fast it runs).</p>
<h2 id="hThreads">Worker Threads</h2>
<p>Another feature of HTML5 is <a href="http://www.whatwg.org/specs/web-workers/current-work/">Web Workers</a>, this allows breaking out of JavaScript&#8217;s natural single threaded nature and perform calculations in separate threads. In order to prevent data races the worker threads can&#8217;t access the browser&#8217;s DOM which slightly limits their usage.</p>
<p>Thankfully number crunching doesn&#8217;t require access to the DOM and I had a chance to implement Collatz yet again (this is turning into a real <a href="http://en.wikipedia.org/wiki/Kata_%28programming%29">code kata</a>, especially counting all the different <a title="Optimizing Collatz for Klutzes" href="http://lanzkron.wordpress.com/2010/06/02/optimizing-collatz-for-klutzes/">C++ implementations</a> I wrote).</p>
<p>Here I launch a number of threads, each takes a sparse view of the numbers in the range. I keep track of the threads that have reported the maximal orbit for their slice and when all threads have answered I output the answer.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#200080;font-weight:bold;">function</span> parallel<span style="color:#308080;">(</span>limit<span style="color:#308080;">,</span> threads<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">var</span> <span style="color:#200080;font-weight:bold;">max</span> <span style="color:#308080;">=</span> <span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">,</span> <span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> live_threads <span style="color:#308080;">=</span> threads<span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">for</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">var</span> i <span style="color:#308080;">=</span> <span style="color:#008c00;">0</span><span style="color:#406080;">;</span> i <span style="color:#308080;">&lt;</span> threads<span style="color:#406080;">;</span> <span style="color:#308080;">++</span>i<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">var</span> worker <span style="color:#308080;">=</span> <span style="color:#200080;font-weight:bold;">new</span> Worker<span style="color:#308080;">(</span><span style="color:#1060b6;">"euler14.js"</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span> <span style="color:#888888;">// Create thread object</span>
        worker<span style="color:#308080;">.</span>addEventListener<span style="color:#308080;">(</span><span style="color:#1060b6;">'message'</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">function</span> <span style="color:#308080;">(</span>e<span style="color:#308080;">)</span> <span style="color:#406080;">{</span> <span style="color:#888888;">// This function is how the thread reports back</span>
            <span style="color:#200080;font-weight:bold;">var</span> d <span style="color:#308080;">=</span> e<span style="color:#308080;">.</span>data<span style="color:#406080;">;</span>
            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>d<span style="color:#308080;">.</span>len <span style="color:#308080;">&gt;</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
                <span style="color:#200080;font-weight:bold;">max</span> <span style="color:#308080;">=</span> <span style="color:#308080;">[</span>d<span style="color:#308080;">.</span>len<span style="color:#308080;">,</span> d<span style="color:#308080;">.</span>num<span style="color:#308080;">]</span><span style="color:#406080;">;</span>
            <span style="color:#406080;">}</span>

            <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span><span style="color:#308080;">--</span>live_threads <span style="color:#308080;">==</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span> <span style="color:#888888;">// Done, output the result</span>
                report<span style="color:#308080;">(</span><span style="color:#1060b6;">"Parallel ("</span><span style="color:#308080;">+</span> threads <span style="color:#308080;">+</span> <span style="color:#1060b6;">")"</span><span style="color:#308080;">,</span> begin<span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">1</span><span style="color:#308080;">]</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#406080;">}</span><span style="color:#308080;">,</span> <span style="color:#0f4d75;">false</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>

<span style="color:#888888;">        // Launch the thread</span>
        worker<span style="color:#308080;">.</span>postMessage<span style="color:#308080;">(</span><span style="color:#406080;">{</span> <span style="color:#1060b6;">'max'</span><span style="color:#406080;">:</span> limit<span style="color:#308080;">,</span> <span style="color:#1060b6;">'step'</span><span style="color:#406080;">:</span> threads<span style="color:#308080;">,</span> <span style="color:#1060b6;">'offset'</span><span style="color:#406080;">:</span> i <span style="color:#406080;">}</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>
<span style="color:#406080;">}</span></pre>
<p>The thread receives all the information it needs for the computation, when it&#8217;s done it reports its findings to the launcher (via <code style="display:inline;background:#fff;padding:0 1px;">self.postMessage</code>) and  commits suicide.</p>
<pre style="color:#000020;background:#f6f8ff;">self<span style="color:#308080;">.</span>addEventListener<span style="color:#308080;">(</span><span style="color:#1060b6;">'message'</span><span style="color:#308080;">,</span> <span style="color:#200080;font-weight:bold;">function</span> <span style="color:#308080;">(</span>e<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
    <span style="color:#200080;font-weight:bold;">var</span> limit <span style="color:#308080;">=</span> e<span style="color:#308080;">.</span>data<span style="color:#308080;">.</span><span style="color:#200080;font-weight:bold;">max</span><span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> add <span style="color:#308080;">=</span> e<span style="color:#308080;">.</span>data<span style="color:#308080;">.</span>offset<span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> step <span style="color:#308080;">=</span> e<span style="color:#308080;">.</span>data<span style="color:#308080;">.</span>step<span style="color:#406080;">;</span>
    <span style="color:#200080;font-weight:bold;">var</span> <span style="color:#200080;font-weight:bold;">max</span> <span style="color:#308080;">=</span> <span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">,</span> <span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#406080;">;</span>

    <span style="color:#200080;font-weight:bold;">for</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">var</span> i <span style="color:#308080;">=</span> <span style="color:#008c00;">1</span><span style="color:#406080;">;</span> i <span style="color:#308080;">+</span> add <span style="color:#308080;">&lt;</span> limit<span style="color:#406080;">;</span> i <span style="color:#308080;">+=</span> step<span style="color:#308080;">)</span> <span style="color:#406080;">{</span>
        <span style="color:#200080;font-weight:bold;">var</span> length <span style="color:#308080;">=</span> orbit<span style="color:#308080;">(</span>i <span style="color:#308080;">+</span> add<span style="color:#308080;">)</span><span style="color:#406080;">;</span>
        <span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span>length <span style="color:#308080;">&gt;</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">)</span>
            <span style="color:#200080;font-weight:bold;">max</span> <span style="color:#308080;">=</span> <span style="color:#308080;">[</span>length<span style="color:#308080;">,</span> i <span style="color:#308080;">+</span> add<span style="color:#308080;">]</span><span style="color:#406080;">;</span>
    <span style="color:#406080;">}</span>

    self<span style="color:#308080;">.</span>postMessage<span style="color:#308080;">(</span><span style="color:#406080;">{</span> <span style="color:#1060b6;">'num'</span><span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">1</span><span style="color:#308080;">]</span><span style="color:#308080;">,</span> <span style="color:#1060b6;">'len'</span><span style="color:#406080;">:</span> <span style="color:#200080;font-weight:bold;">max</span><span style="color:#308080;">[</span><span style="color:#008c00;">0</span><span style="color:#308080;">]</span><span style="color:#308080;">,</span> <span style="color:#1060b6;">'offset'</span><span style="color:#406080;">:</span> e<span style="color:#308080;">.</span>data<span style="color:#308080;">.</span>offset <span style="color:#406080;">}</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span>
    self<span style="color:#308080;">.</span>close<span style="color:#308080;">(</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span> // Goodbye cruel wrold
<span style="color:#406080;">}</span><span style="color:#308080;">,</span> <span style="color:#0f4d75;">false</span><span style="color:#308080;">)</span><span style="color:#406080;">;</span></pre>
<p>IE9 does not support Web Workers and the numbers I got when running Firefox and Chrome on this varied greatly between runs but here are the best times they achieved on my ageing dual core laptop.</p>
<p><a href="http://lanzkron.files.wordpress.com/2011/03/threads.png"><img class="aligncenter size-full wp-image-689" title="Threads" src="http://lanzkron.files.wordpress.com/2011/03/threads.png?w=510&#038;h=315" alt="" width="510" height="315" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lanzkron.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lanzkron.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lanzkron.wordpress.com/678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lanzkron.wordpress.com&amp;blog=10064043&amp;post=678&amp;subd=lanzkron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lanzkron.wordpress.com/2011/03/27/meaningless-benchmark-redux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6183c6f9d621a125cd3aa0f7ae324285?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">lanzkron</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/03/old.png" medium="image">
			<media:title type="html">Old versions</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/03/current.png" medium="image">
			<media:title type="html">Current versions</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/03/canvas.png" medium="image">
			<media:title type="html">Orbit of Collatz 87</media:title>
		</media:content>

		<media:content url="http://lanzkron.files.wordpress.com/2011/03/threads.png" medium="image">
			<media:title type="html">Threads</media:title>
		</media:content>
	</item>
	</channel>
</rss>
