<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>xosfaere</title>
	<atom:link href="http://xosfaere.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xosfaere.wordpress.com</link>
	<description>Travelling at the outer edge of the blogosphere</description>
	<lastBuildDate>Sun, 08 Nov 2009 14:55:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='xosfaere.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/e8a3173501c961ad6d00a6c61363e2f8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>xosfaere</title>
		<link>http://xosfaere.wordpress.com</link>
	</image>
			<item>
		<title>The Effect Spectrum (I)</title>
		<link>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/</link>
		<comments>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:51:14 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Effect]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Pure]]></category>
		<category><![CDATA[Purity]]></category>
		<category><![CDATA[State]]></category>
		<category><![CDATA[Time]]></category>
		<category><![CDATA[Transition]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=595</guid>
		<description><![CDATA[Effects of Intuition
In the march of pure functional programming toward pervasive mainstream use the notion of effects have become an interesting topic. I&#8217;ve begun looking at what you might call &#8220;the effect spectrum&#8221; or &#8220;the effect zoo&#8221;: the different kinds of effects and what they do (to your program).
I shall name these functions by personal preference, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=595&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Effects of Intuition</strong></p>
<p>In the march of pure functional programming toward pervasive mainstream use the notion of effects have become an interesting topic. I&#8217;ve begun looking at what you might call &#8220;the effect spectrum&#8221; or &#8220;the effect zoo&#8221;: the different kinds of effects and what they do (to your program).</p>
<p>I shall name these functions by personal preference, these names are likely unconventional but they have &#8220;symbolic&#8221; value.The first examples will not be effects at all but I will gradually move into effects over the next few posts, well maybe just one more post. I have a few ideas queued up on time-slicing, &#8220;forced&#8221; pre-emption (OS terminology abuse alert) and exceptions.</p>
<p>The structural notation will be a &#8220;pseudo/semi-formalism&#8221;, Haskell-like.</p>
<p><strong>Exhibit 1: Non [ineffective]</strong></p>
<p>This function takes no arguments, computes nothing, does nothing and returns no result. It is the computational equivalent of brain death.</p>
<p><em>structure</em></p>
<p style="padding-left:30px;">() → ()</p>
<p><em>substance</em></p>
<p style="padding-left:30px;">public void non()<br />
{<br />
}</p>
<p><strong>Exhibit 2: Som [ineffective]</strong></p>
<p>This function takes one argument and returns that argument. The &#8220;zero&#8221; function may be seen as a special case of the &#8220;one&#8221; function, accepting only the empty tuple.</p>
<p><em><em>structure</em></em></p>
<p style="padding-left:30px;">a → a</p>
<p><em><em>substance</em></em></p>
<p style="padding-left:30px;">public void som&lt;T&gt; (T x)<br />
{<br />
&nbsp;&nbsp;return x;<br />
}</p>
<p><strong>Exhibit 3: Som-Non [ineffective]</strong></p>
<p>This function takes one argument and returns nothing as a result, never caring about what the argument actually was, you might call this a comatose function: it gets everything you say but can&#8217;t respond back with anything (the empty tuple () being the equivalent of silence).</p>
<p><em><em>structure</em></em></p>
<p style="padding-left:30px;">a → ()</p>
<p><em><em>substance</em></em></p>
<p style="padding-left:30px;">public void somnon&lt;T&gt; (T x)<br />
{<br />
}</p>
<p><strong>Exhibit 4: Non-Som [ineffective]</strong></p>
<p>This function takes nothing and returns something. It is the dual of comatose &#8211; it can only give and it always gives the same thing.</p>
<p><em>structure</em></p>
<p style="padding-left:30px;">() → a</p>
<p><em>substance</em></p>
<p style="padding-left:30px;">public T nonsom&lt;T&gt;()<br />
{<br />
&nbsp;&nbsp; return default(T);<br />
}</p>
<p><strong>Exhibit 5: Som-Time [time-"in"-effective]</strong></p>
<p>This function takes something and returns that same thing, after some time. You might say it&#8217;s the functional equivalent of bullet-time; it slows down time (if e.g. we define time as state-transitions; ticks, or whatever). This means it has an effect, meaning its &#8220;effective&#8221; but this time-effect also makes it &#8220;in-effective&#8221;.</p>
<p><em>structure</em></p>
<p style="padding-left:30px;">a → Δ a</p>
<p><em>substance</em></p>
<p style="padding-left:30px;">public T somtime&lt;T&gt;(T x)<br />
{<br />
&nbsp;&nbsp; Thread.Sleep(1000);<br />
&nbsp;&nbsp; return x;<br />
}</p>
<p>One may argue whether this function actually contains a [side-]effect (messing with time) or not. In a sense all functions mess with time, as in the real world they take time to compute. So the result is some delta into the future where the argument is some point in the past, depending on when you look at it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/595/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=595&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Types &#8211; Arrows &#8211; Duals</title>
		<link>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 00:56:57 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Arrows]]></category>
		<category><![CDATA[Brainstorm]]></category>
		<category><![CDATA[Channel 9]]></category>
		<category><![CDATA[DOCX]]></category>
		<category><![CDATA[Duals]]></category>
		<category><![CDATA[Erik Meijer]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Lecture Notes]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Types]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=592</guid>
		<description><![CDATA[As part of my continued pursuit of the Lambda Lecture Series (my name for it) on Channel 9, I&#8217;ve summoned up a brain-storm worth of examples that show the symmetry and dualism of some functions and types. I&#8217;m not yet familiar with the higher-level abstract concepts of Arrows so arrow here simply means function.
References
 &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=592&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As part of my continued pursuit of the Lambda Lecture Series (my name for it) on Channel 9, I&#8217;ve summoned up a brain-storm worth of examples that show the symmetry and dualism of some functions and types. I&#8217;m not yet familiar with the higher-level abstract concepts of Arrows so arrow here simply means function.</p>
<p><strong>References<br />
</strong> &#8211; <a href="http://cid-e189d6f0d12fdc06.skydrive.live.com/browse.aspx/Public/Types%20Arrows%20Duals?uc=5">Types &#8211; Arrows &#8211; Duals</a> [SkyDrive]</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/592/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=592&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Adversus Nullus, Unnullable&lt;T&gt;</title>
		<link>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 19:58:21 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Generic]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Non-Null]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[Nullable]]></category>
		<category><![CDATA[Nullpointer]]></category>
		<category><![CDATA[Safety]]></category>
		<category><![CDATA[Struct]]></category>
		<category><![CDATA[Unnullable]]></category>
		<category><![CDATA[Void-safety]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=571</guid>
		<description><![CDATA[Let&#8217;s fix C.A.R. Hoare&#8217;s billion dollar mistake for C#: Null-pointer dereferences. &#8211; Isn&#8217;t hindsight great?
By default, C# reference types are nullable, meaning one can assign a null value to a variable of a reference type. These null values can propagate away from the point of origin and spread terror and havoc. There is a good [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=571&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Let&#8217;s fix <a href="http://en.wikipedia.org/wiki/C._A._R._Hoare">C.A.R. Hoare</a>&#8217;s <a href="http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare">billion dollar mistake</a> for C#: Null-pointer dereferences. &#8211; Isn&#8217;t hindsight great?</p>
<p>By default, C# reference types are nullable, meaning one can assign a null value to a variable of a reference type. These null values can propagate away from the point of origin and spread terror and havoc. There is a good and sound principle in software engineering that says: <em>fail early, fail often</em>. This means that a program should detect or exhibit a software defect right where it occurs (which is as soon as it occurs; well possibly sooner using static analysis and symbolic execution) and it should exibit a predictable behavior towards it, failing each time, reflexively. A program that just carries on can end up making much more damage along the way and can be harder to debug.</p>
<p>Then of course we might choose to interpret what we mean by &#8220;fail&#8221;. It might be a brutal failure or a recovered failure. The base philosophy has to be that the defect is at least signalled at its origin, handled or not.</p>
<p>One approach to dealing with this issue is using contracts. One can annotate function and method definitions with pre- and post-conditions expressing that the input and output of a piece of code will not and must not accept or deliver a null value. If spread everywhere, this will help catch the error where it occurs. It&#8217;s like a finely masked web spread out over the code, which will not allow a null value much freedom to move around before it is caught: thus enforcing the fail fast principle.</p>
<p>In Microsoft .Net, traditionally, there has not been support for contract programming or what is known as Design by Contract from Eiffel. People can write their own assert functions and sprinkle them all over the place which may help but it is not a very good contract solution. Things improve in .Net 4.0 with language-agnostic contract support.</p>
<p>A different approach is to have types help out.</p>
<p>In software engineering we face the same problem over and over again: in an imperative world it used to be fine to have object be mutable by default. In the new manycore world this approach is untennable. Similarly, in the past, it used to be (somewhat) ok to have reference types include null in the domain. It just turns out that in practice this was a really bad mistake. Null-pointer exceptions én masse. In the first case a paradigm shift forces us to change strategy, at least gradually. In the second, a painful history of bugs teaches us better ways.</p>
<p>As an aside, recently Dr. Erik Meijer and team have dualized the <em>IEnumerable/IEnumerator</em> types, creating the quite beautiful <em>IObservable/IObserver</em> types. In other words, the two type sets form eachothers duals. That is not to say that the former is no longer needed but it&#8217;s one more example of dualization. Mutable vs Immutable another (well an opposite at least).</p>
<p>New since, what, .Net 2.0 is Nullable&lt;T&gt;. This type allows us to define primitive (struct) types as nullable by wrapping them in another type that signal whether the wrapped value is actually null. It will not work for classes since they are already nullable and the Nullable type is defined to only work for T where T is a struct type.</p>
<p>The obvious thought here is: OK, we had integers that we needed to be nullable. Now we have objects that we need not to be nullable. Let&#8217;s &#8220;dualize&#8221; this. And so I made a simple struct to demonstrate the idea. This would benefit from language support but can really help out on its own. The Nullable&lt;T&gt; type has syntactic support in C# via the T? notation.</p>
<p>The definition is as follows.</p>
<p><span>&nbsp;&nbsp;public struct Unnullable&lt;T&gt; where T : class<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;public Unnullable(T x)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (x == null)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new NullReferenceException();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item = x;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;public T Item<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return item;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;private readonly T item;<br />
&nbsp;&nbsp;}</span></p>
<p>I made it up an early morning, after waking up far far too early and it has to be tested out thouroughly. But just quickly trying some obvious null assignments fails. Even not assigning a value to a newly declared Unnullable&lt;T&gt; variable will fail at compile-time; well, even before, as Intellisense and background compilation will warn you before you run a regular compile. At least if you use Visual Studio.</p>
<p>It&#8217;s impossible to construct an Unmutable that contains a null. So it really is <em>un-nullable</em>. At least if not resorting to evil means such as reflection. If this type is used, whereever it is used it will provide null-safety, i.e. non-nullness.</p>
<p>In a not too distant future we may see this built into C# and VB, maybe even on the class level where we can say that a class is unnullable by design. This may create other problems that we&#8217;ll defer indefinitely &#8211; for now.</p>
<p><strong>References</strong></p>
<p>- <a href="http://channel9.msdn.com/forums/TechOff/499699-Suggestions-for-C-50/#Page=2">A Channel 9 thread on ideas for C# 5.0</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/571/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=571&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Lambda Lecture Series</title>
		<link>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:50:30 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[$]]></category>
		<category><![CDATA[.]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Channel 9]]></category>
		<category><![CDATA[Charles Torre]]></category>
		<category><![CDATA[Composition]]></category>
		<category><![CDATA[Dr. Erik Meijer]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Expression]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[Infix]]></category>
		<category><![CDATA[λ]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Lecture]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Material]]></category>
		<category><![CDATA[Operator]]></category>
		<category><![CDATA[Prefix]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[\]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=555</guid>
		<description><![CDATA[There is a new lecture series on Channel 9 by Dr. Erik Meijer. It is about functional programming and is using Haskell as the the means of expression although the exact language is not so important; but Haskell is appropriate in that it is pure, lazy and has a discrete syntax.
There was a couple of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=555&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There is a new lecture series on Channel 9 by Dr. Erik Meijer. It is about functional programming and is using Haskell as the the means of expression although the exact language is not so important; but Haskell is appropriate in that it is pure, lazy and has a discrete syntax.</p>
<p>There was a couple of questions about the execution of the programs in the beginning of the series and so for weekend fun I prepared a small document that shows two different (actually not so different) REPL&#8217;s. These may be used to execute Haskell expressions directly.</p>
<p>References</p>
<ul>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/">Lecture Series</a> [channel 9]</li>
<li><a href="http://cid-e189d6f0d12fdc06.skydrive.live.com/browse.aspx/Public/Lambda%20Lecture%20Series">Lecture Reference</a> [SkyDrive]</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/555/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=555&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Let there be chaos – sort of</title>
		<link>http://xosfaere.wordpress.com/2009/10/04/let-there-be-chaos/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/04/let-there-be-chaos/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 22:44:06 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Nature]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Universe]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Chaos]]></category>
		<category><![CDATA[Extension Method]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Order]]></category>
		<category><![CDATA[Predictability]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=530</guid>
		<description><![CDATA[Program code follows order. Syntax and semantics. But when run, it can be very unpredictable and unordered. Chaos out of order you might say. A clear picture of this are fractals (although they embody both order and chaos at the same time); a better example may be random numbers.
Actually, most of the time we deal [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=530&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Program code follows order. Syntax and semantics. But when run, it can be very unpredictable and unordered. Chaos out of order you might say. A clear picture of this are fractals (although they embody both order and chaos at the same time); a better example may be random numbers.</p>
<p>Actually, most of the time we deal with pseudo-random numbers, that is, numbers that operate on a seed value and calculate some other number based on this seed value. But then, if we know the seed value, we can compute the &#8220;random&#8221; number, so unless the seed value itself is random, we don&#8217;t have a truly random number.</p>
<p>More troublingly, how can we even determine that a number is random? Well, let&#8217;s not go there. Instead, let&#8217;s try to bring order to the chaos that is randomness in Random in the .Net Framework. In particular, rather than fetching one &#8220;random&#8221; number at a time, we should see randomness is a stream of numbers.</p>
<p>So the definition* is as follows</p>
<pre><code>public static IE&lt;int&gt; Random(this int seed,
     int min = 0, int max = int.MaxValue)
{
    var r = new Random(seed);
    while (true)
        yield return r.Next(min, max);
}</code></pre>
<p></p>
<p>So this looks pretty good, now instead of calling r.Next explicitly, and thereby invoking a side-effect, we just get a sequence of pseudo-random or chaotic numbers based on a seed value.</p>
<p>This means we have pure randomness: functional randomness where chaos is a function of order, that is we get the same randomness for the same seed, every time; at least unless the implementation of Random breaks and suddenly gives us new randomness for the same seed value; something which would be highly&#8230; irregular.</p>
<p>Now we can create a random combinator which given an IEnumerable and a seed value, will predictably randomize this IEnumerable into a new IEnumerable.</p>
<pre><code>public static IE&lt;T&gt; Random&lt;T&gt;(this IE&lt;T&gt; s, int seed = 0)
{
    var n = s.Count();
    return from i in seed.Random(0, n).Distinct().Take(n)
           select s.ElementAt(i);
}</code></pre>
<p></p>
<p>Simple, predictable, composable.</p>
<p>Now looking back at the previous post &#8220;Information&#8221;, we might be inspired to decompose randomness into a stream of bits instead; I mean, why should we deal with pesky integers. Looks like a random choice of number system to me.</p>
<pre><code>public static IE&lt;bool&gt; Random(this bool seed)
{
    var r = new Random(seed ? 1 : 0);
    while (true)
        yield return r.Next(0,1) == 1;
}</code></pre>
<p></p>
<p>And so there you go. Pure, predictable, pseudo-random numbers in the most simple package there is: a stream of bits.</p>
<p>* <strong>Notice</strong> that IE is short-hand for IEnumerable.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/530/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=530&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/04/let-there-be-chaos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Information</title>
		<link>http://xosfaere.wordpress.com/2009/10/04/information/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/04/information/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 22:17:57 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Bit]]></category>
		<category><![CDATA[Bitstream]]></category>
		<category><![CDATA[bool]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[extremist]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[IEnumerable]]></category>
		<category><![CDATA[Information Theory]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[stream]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=526</guid>
		<description><![CDATA[I have always been interested in breaking down data and concepts into fundamental pieces. In a way everything can be decomposed into bits, at least in the realm of data. 
And so it always appeared unnatural to me that programming languages or libraries did not naturally express this this fact that the bit is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=526&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have always been interested in breaking down data and concepts into fundamental pieces. In a way everything can be decomposed into bits, at least in the realm of data. </p>
<p>And so it always appeared unnatural to me that programming languages or libraries did not naturally express this this fact that the bit is the unit of information. This is particularly unnatural when dealing with information where data that is not neatly packed into bytes. A truly compositional way of parsing should build upon bits, even if at least 8 bits or more are read from disk, memory or whereever.</p>
<p>So I set out to formulate this in C#. This is only the beginning but here&#8217;s what the very initial alpha functions code looks like.</p>
<p>First we define* decomposition for bool values (bits), this is obviously the simplest case as we cannot decompose this case (well, we could, but let&#8217;s not go there)</p>
<pre><code>public static IE&lt;bool&gt; Information(this bool x)
{
    yield return x;
}</code></pre>
<p></p>
<p>Next we decompose bytes</p>
<pre><code>public static IE&lt;bool&gt; Information(this byte x)
{
    return Enumerable.Range(0, 8 )
           .Select(i =&gt; ((x &gt;&gt; i) &amp; 1) == 1)
           .Normalize();
}</code></pre>
<p></p>
<p>Then we define a normalization combinator that orders bits according to the current architechture&#8217;s Endianness</p>
<pre><code>public static IE&lt;bool&gt; Normalize(this IE&lt;bool&gt; s)
{
    return BitConverter.IsLittleEndian ? s.Reverse() : s;
}</code></pre>
<p></p>
<p>And so on and so forth. As you can see this is very limited so far, but you can imagine combining these to decompose byte streams from files, etc. And so this will allow you do be completely oblivious to endianness and decomposition of bytes etc. All you see are bitstreams.</p>
<p>As said, this is alpha. I have almost no experience with binary parsing and such, but this should be interesting for diving into that area.</p>
<p>* <strong>Notice</strong> that IE is short-hand for IEnumerable!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/526/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=526&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/04/information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Choice, An Algebraic Answer</title>
		<link>http://xosfaere.wordpress.com/2009/09/20/choice-an-algebraic-answer/</link>
		<comments>http://xosfaere.wordpress.com/2009/09/20/choice-an-algebraic-answer/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 11:27:56 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ADT]]></category>
		<category><![CDATA[Algebraic Data Type]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=472</guid>
		<description><![CDATA[C# allows you to model sets via enumerations (the enum kind of type). Take for example
public enum Choice
{
    Either,
    Or
}
.
Now how if one wanted to model not just a choice but a choice between values. There is no way to do that with C# enums as of today.
Languages with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=472&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>C# allows you to model sets via enumerations (the enum kind of type). Take for example</p>
<pre><code>public enum Choice
{
    Either,
    Or
}
.</code></pre>
<p>Now how if one wanted to model not just a choice but a choice between values. There is no way to do that with C# enums as of today.</p>
<p>Languages with algebraic data types (ADTs) allow this, witness this example</p>
<pre><code>public enum Either&lt;α, β&gt;
{
    either(x: α);
    or(x : β);
}
.</code></pre>
<p>Notice that this specification does not depend on the choice of values to necessarily have the same type or any particular type, this is just using parametric polymorphism. Don&#8217;t be distracted by the greek symbols, you could have used any identifier, such as S and T, as is common in .Net land.</p>
<p>Suffice it to say I wanted to adapt this for C# to see if I could possibly model choice in a nice way. And so I first tried this</p>
<pre><code>public enum Choice
{
    Either,
    Or
}

public sealed class Either&lt;α, β&gt;
{
    private Either(α a = default(α), β b = default(β))
    {
        this.First = a;
        this.Second = b;
    }

    ...

    public readonly α First;

    public readonly β Second;

    public readonly Choice Choice;
}
.</code></pre>
<p>Now of course in this example we could have used a bool because the set only has two types, but really we don&#8217;t want to be limited to that, and we also want the type to say what &#8220;true&#8221; is and what &#8220;false&#8221; is.</p>
<p>The real dissatisfying aspect of this solution is that it separates the &#8220;tag set&#8221; from the value set &#8211; you have two constructs instead of one. This is clearly a dissatisfactory solution.</p>
<p>And so working a bit more with this, I came up with this solution</p>
<pre><code>public abstract class Choice&lt;α, β&gt;
{
    protected Choice(α a = default(α), β b = default(β))
    {
        this.First = a;
        this.Second = b;
    }

    public readonly α First;

    public readonly β Second;
}

public sealed class Either&lt;α, β&gt; : Choice&lt;α, β&gt;
{
    public Either(α x)
        : base(x, default(β))
    {
    }
}

public sealed class Or&lt;α, β&gt; : Choice&lt;α, β&gt;
{
    public Or(β x)
        : base(default(α), x)
    {
    }
}
.</code></pre>
<p>This specification, although not as clean as a pure ADT specification, has desirable properties. A type of choice is expressed as a subtype. Testing a value for what kind of choice it is amounts to using the is operator, as in &#8220;a is Either&lt;int,bool&gt;&#8221;.</p>
<p>I&#8217;m going to be experimenting with what can be done with this style and this type family in particular.</p>
<p>The solution has some validation because I believe it is similar to the hybrid functional object-oriented language Scala uses, which is quite state-of-the-art in this respect; some memories of Scala must have been floating around when solving this.</p>
<p>Feel free to use.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/472/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=472&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/09/20/choice-an-algebraic-answer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Timer.µs.Time(() =&gt; work())</title>
		<link>http://xosfaere.wordpress.com/2009/09/19/higher-order-high-resolution-timer-for-the-masses/</link>
		<comments>http://xosfaere.wordpress.com/2009/09/19/higher-order-high-resolution-timer-for-the-masses/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 22:20:40 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Codeplex]]></category>
		<category><![CDATA[Extensia]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Stopwatch]]></category>
		<category><![CDATA[Timer Extension Method]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=455</guid>
		<description><![CDATA[Or -
Higher-Order High-Resolution Timer for the Masses
Timing code is so common that many timers exist in the .Net Framework. One can resort to simplistic timing via Environment.TickCount DateTime.Now, but this is a low-resolution timer that does not accurately reflect the current tick count and is therefore not usable for precision timing. As this[1] MSDN article [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=455&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Or -</p>
<blockquote><p>Higher-Order High-Resolution Timer for the Masses</p></blockquote>
<p>Timing code is so common that many timers exist in the .Net Framework. One can resort to simplistic timing via <del><code>Environment.TickCount</code></del> <code>DateTime.Now</code>, but this is a low-resolution timer that does not accurately reflect the current tick count and is therefore not usable for precision timing. As this[1] <a href="http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx">MSDN article</a> shows, its resolution is actually 10 ms for modern versions of Windows (NT 3.5 or later).</p>
<p>Also see <a href="http://reflexangle.blogspot.com/2009/04/datetimenow-vs-systemdiagnosticsstopwat.html">this</a>[2] article about three timing tactics for .Net.</p>
<p><code>(System.Diagnostics.) Stopwatch</code> to the rescue. This class is a simple stopwatch that is easy to use. However even this class can be repetitive to use many times. The way to make this even easier is to create a higher-order function. I wanted to create such a function but figured it would be nice to include in my extension method library on codeplex.</p>
<p>The problem is that dispatching off an action is not nice (not even the latest C# 4.0 mitigates this). So I created a new enum type Timer that reflects two units of measure &#8211; ticks and milliseconds. Now an extension method can dispatch over this type and measure time for a delegate. This is how the code is used (work is an Action that performs the work to be timed)</p>
<pre><code>var ms = Timer.ms.Time(() =&gt; work());</code>
</pre>
<p></p>
<p>I dare you to simplify this. See code on <a href="http://extensia.codeplex.com">extensia</a>[3] on <a href="http://extensia.codeplex.com/">codeplex</a>.</p>
<p>If C# worked a little more like I&#8217;d like it to, it&#8217;d be possible to write something like this, using extension methods</p>
<pre><code>var ms = Work.Time();</code>
</pre>
<p></p>
<p>Maybe C# 5.0.</p>
<p>The latest improvement here, is a method to show (via <code>(System.Diagnostics.) Trace</code>, which can be fed into the Console via a listener) the timing information in a nicely formatted way &#8211; it allows you to write this</p>
<pre><code>Timer.µs.Show(() =&gt; Test(), "test");
Timer.Ticks.Show(() =&gt; Test(), "test");</code>
</pre>
<p></p>
<p>The first line displays the measurements in whole microseconds, the seond one in the unit closest to the order of magnitude below or equal to one second. This eases formatting quite a bit. The output of a Ticks measurement looks like</p>
<p><em>test() finished in 235025 ticks (100 ms)</em></p>
<p>As you can see the appropriate unit (milliseconds) is chosen. This number is calculated based on Stopwatch.Frequency which defines the resolution of the underlying timer.</p>
<p>Notice the that the special character &#8220;µ&#8221;, which is a nice cherry on the top for this interface. I have also begun using the greek alpha, beta and gamma symbols for parametric type names to make them stand out more (although these symbols are also be useful for math variables, so it&#8217;s not a clear cut case on their usability for this purpose).</p>
<p><strong>2009/10/10</strong>: updated the post with a correction and a couple of references: it is not Environment.TickCount that is (necessarily) imprecise (relatively speaking), it is DateTime.Now. However Stopwatch is the best approach to timing precisely since it exposes the timing frequency and whether the timer is actually high-precision as a boolean property (Environment does not appear to expose frequency information) and it is supposedly the highest-precision timer in the .Net Framework (BCL).</p>
<p>References</p>
<ul>
<li>[1] http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx</li>
<li>[2] http://reflexangle.blogspot.com/2009/04/datetimenow-vs-systemdiagnosticsstopwat.html</li>
<li>[3] http://extensia.codeplex.com</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/455/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=455&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/09/19/higher-order-high-resolution-timer-for-the-masses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>{Unqualified}Linq</title>
		<link>http://xosfaere.wordpress.com/2009/09/19/unqualified-linq/</link>
		<comments>http://xosfaere.wordpress.com/2009/09/19/unqualified-linq/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 22:00:18 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Extension Method]]></category>
		<category><![CDATA[infoset]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Local Name]]></category>
		<category><![CDATA[Namespaceless]]></category>
		<category><![CDATA[QName]]></category>
		<category><![CDATA[XLinq]]></category>
		<category><![CDATA[XName]]></category>
		<category><![CDATA[XNamespace]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=436</guid>
		<description><![CDATA[I have been increasingly using XLinq for various small tasks and it really is quite productive.
Recently however, a problem arose whereby a colleague asked for a solution to how he could possibly deal with XML documents with any namespaces in the same way.
That is, it whether an element was called {foo}bar or {}bar could not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=436&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have been increasingly using XLinq for various small tasks and it really is quite productive.</p>
<p>Recently however, a problem arose whereby a colleague asked for a solution to how he could possibly deal with XML documents with <strong>any</strong> namespaces in the <strong>same</strong> way.</p>
<p>That is, it whether an element was called {foo}bar or {}bar could not have any significance to his code.</p>
<p>Therefore I devised a couple of simple extension methods to deal with this issue. The solution, which is easily replicatable with a little knowledge of LINQ and System.Xml.Linq, is used like this</p>
<pre><code>var isbn = doc.LElement("book").LElement("isbn");
</code></pre>
<p><span>.</span><br />
I reimplemented these with provisions for attribute support on <a href="http://extensia.codeplex.com">extensia.codeplex.com</a> &#8211; feel free to use.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/436/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=436&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/09/19/unqualified-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Console Extension Methods</title>
		<link>http://xosfaere.wordpress.com/2009/09/19/console-extension-methods-revisited/</link>
		<comments>http://xosfaere.wordpress.com/2009/09/19/console-extension-methods-revisited/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 21:16:06 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Arguments]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[Exceptions]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Parameters]]></category>
		<category><![CDATA[Parsing]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/2009/09/19/console-extension-methods-revisited/</guid>
		<description><![CDATA[In the first post on console extension methods I showed how to parse console arguments in an extremely simple way. However this is not quite optimal for formatting exceptions for missing argument exceptions because the distinctions are erased.
Therefore I devised a new way to deal with this where these cases are surfaced as exceptions. It&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=428&subd=xosfaere&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In the first post on console extension methods I showed how to parse console arguments in an extremely simple way. However this is not quite optimal for formatting exceptions for missing argument exceptions because the distinctions are erased.</p>
<p>Therefore I devised a new way to deal with this where these cases are surfaced as exceptions. It&#8217;s pretty simple but nice because since the parameter name is known, it can be used to give very helpful error messages in a catch block.  So the idea is to keep the entire console application parsing code in a try block and keep the exceptions separate.</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Text;

<span class="kwrd">namespace</span> Tests
{
    <span class="kwrd">using</span> Extensia.Console;

    <span class="kwrd">class</span> Program
    {
        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
        {
            <span class="kwrd">try</span>
            {
                var price = args.Argument&lt;<span class="kwrd">decimal</span>&gt;(<span class="str">"price"</span>);
            }
            <span class="kwrd">catch</span> (Exception e)
            {
                <span class="rem">// we get nice exceptions here a la</span>
                <span class="rem">// - argument missing for "speed"</span>
                <span class="rem">// - unsupported format for "speed"</span>
                <span class="rem">// - format error for "speed"</span>
                Console.WriteLine(e.Message);
            }
        }
    }
}</pre>
<p>This is a nice and simple model that is even better than the previous one.</p>
<p>The solution (up on <a href="http://extensia.codeplex.com">extensia.codeplex.com</a>) - feel free to download and use it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/428/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&blog=1884763&post=428&subd=xosfaere&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/09/19/console-extension-methods-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6be2b05651a4b43e5ec80e5c051eb90?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
	</channel>
</rss>