<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Passing Curiosity: Posts tagged programming</title>
    <link href="https://passingcuriosity.com/tags/programming/programming.xml" rel="self" />
    <link href="https://passingcuriosity.com" />
    <id>https://passingcuriosity.com/tags/programming/programming.xml</id>
    <author>
        <name>Thomas Sutton</name>
        
        <email>me@thomas-sutton.id.au</email>
        
    </author>
    <updated>2010-05-11T00:00:00Z</updated>
    <entry>
    <title>Providing default settings for Django applications</title>
    <link href="https://passingcuriosity.com/2010/default-settings-for-django-applications/" />
    <id>https://passingcuriosity.com/2010/default-settings-for-django-applications/</id>
    <published>2010-05-11T00:00:00Z</published>
    <updated>2010-05-11T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>The problem is a simple one: you’re writing a Django application that needs a
setting or two. You know what they’ll be in the vast majority of cases but you
want to make them configurable, just in case. As you’re a good developer you
live by the maxim: Don’t Repeat Yourself so you’d like to define each of these
values and, for ease of documentation, all of them in one place. Alas, you’re
out of luck: Django does not provide any support for applications to supply
their own default values for settings. Thankfully though, all it takes is a
few lines of code and your application can shoehorn its own default values
into the global settings system.</p>
<p>First, a proviso to what follows: I am almost certain that this is a bad idea
and that you should do it. At the very least, you should make sure that your
setting names don’t clash (I like to prefix them with the app name).</p>
<p>The goal is simple: your app should contain a <code>settings</code> module which defines
the default values for your application’s settings. These values should be
injected into Django’s settings system so that <code>manage.py diffsettings</code> and
similar functionality all work as you’d expect.</p>
<p>The approach is just as simple: add some code to the top-level module of your
application that loops over the values in your <code>app.settings</code> module and
inject them into the <code>django.conf.global_settings</code> module and (because it’s
already been initialised by the time apps are loaded) the
<code>django.conf.settings</code> object (being careful not to stop on actual configured
with your default values).</p>
<p>The code itself is pretty simple. From <code>app/__init__.py</code>:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> inject_app_defaults(application):</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>	<span class="co">&quot;&quot;&quot;Inject an application's default settings&quot;&quot;&quot;</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>	<span class="cf">try</span>:</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>		<span class="bu">__import__</span>(<span class="st">'</span><span class="sc">%s</span><span class="st">.settings'</span> <span class="op">%</span> application)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>		<span class="im">import</span> sys</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>		</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>		<span class="co"># Import our defaults, project defaults, and project settings</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a>		_app_settings <span class="op">=</span> sys.modules[<span class="st">'</span><span class="sc">%s</span><span class="st">.settings'</span> <span class="op">%</span> application]</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>		_def_settings <span class="op">=</span> sys.modules[<span class="st">'django.conf.global_settings'</span>]</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>		_settings <span class="op">=</span> sys.modules[<span class="st">'django.conf'</span>].settings</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>		<span class="co"># Add the values from the application.settings module</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>		<span class="cf">for</span> _k <span class="kw">in</span> <span class="bu">dir</span>(_app_settings):</span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a>			<span class="cf">if</span> _k.isupper():</span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>				<span class="co"># Add the value to the default settings module</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a>				<span class="bu">setattr</span>(_def_settings, _k, <span class="bu">getattr</span>(_app_settings, _k))</span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a>				</span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a>				<span class="co"># Add the value to the settings, if not already present</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a>				<span class="cf">if</span> <span class="kw">not</span> <span class="bu">hasattr</span>(_settings, _k):</span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a>					<span class="bu">setattr</span>(_settings, _k, <span class="bu">getattr</span>(_app_settings, _k))</span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a>	<span class="cf">except</span> <span class="pp">ImportError</span>:</span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a>		<span class="co"># Silently skip failing settings modules</span></span>
<span id="cb1-23"><a href="#cb1-23" aria-hidden="true" tabindex="-1"></a>		<span class="cf">pass</span></span>
<span id="cb1-24"><a href="#cb1-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-25"><a href="#cb1-25" aria-hidden="true" tabindex="-1"></a>inject_app_defaults(<span class="va">__name__</span>)</span></code></pre></div>
<p>You can see the code in a proof of concept application in my
<a href="http://github.com/thsutton/django-application-settings/">django-application-settings</a> project on GitHub.</p>]]></summary>
</entry>
<entry>
    <title>Updating an INI file with AWK</title>
    <link href="https://passingcuriosity.com/2010/updating-an-ini-file-with-awk/" />
    <id>https://passingcuriosity.com/2010/updating-an-ini-file-with-awk/</id>
    <published>2010-04-14T00:00:00Z</published>
    <updated>2010-04-14T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>The problem is simple: update a specific line in a specific section of a
<code>.ini</code> file in a shell script. The file (a configuration file for Gitosis)
looks something like this:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode ini"><code class="sourceCode ini"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">[gitosis]</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="kw">[repo repo1]</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="dt">description </span><span class="ot">=</span><span class="st"> This is a repository with stuff in it</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="dt">owner </span><span class="ot">=</span><span class="st"> A User</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="kw">[repo repo2]</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="dt">description </span><span class="ot">=</span><span class="st"> Another repository with stuff in it</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="dt">owner </span><span class="ot">=</span><span class="st"> Another User</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="kw">[repo docs]</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="dt">description </span><span class="ot">=</span><span class="st"> Documentation</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="dt">owner </span><span class="ot">=</span><span class="st"> A Manager</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="kw">[group developers]</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="dt">writable </span><span class="ot">=</span><span class="st"> repo1 repo2 docs</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="dt">members </span><span class="ot">=</span><span class="st"> auser anotheruser</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a><span class="kw">[group managers]</span></span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a><span class="dt">writable </span><span class="ot">=</span><span class="st"> docs</span></span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a><span class="dt">readonly </span><span class="ot">=</span><span class="st"> repo1</span></span></code></pre></div>
<p>The goal is to append a value to the <code>writable</code> line in the <code>group developers</code>
section (leaving the rest of the lines alone). Any solution will need to do
the following:</p>
<ol type="1">
<li>find the <code>group developers</code> section; then</li>
<li>find the <code>writable</code> line in that section, if any, and update it.</li>
</ol>
<p>This is simple to do in AWK:</p>
<ol type="1">
<li>a rule sets a flag when you enter the <code>group developers</code> section;</li>
<li>another updates the <code>writable</code> line when the flag is set;</li>
<li>a thirds rule clears the flag when you leave the section;</li>
<li>a final rule outputs other lines unchanged (we use a flag to skip the lines
modified and output above).</li>
</ol>
<p>Here’s the code:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode awk"><code class="sourceCode awk"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Clear the flag</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="cf">BEGIN</span> <span class="op">{</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>	processing <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Entering the section, set the flag</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ot">/^\</span><span class="sc">[</span><span class="ss">group developers</span><span class="ot">/</span> <span class="op">{</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>	processing <span class="op">=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>	</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co"># Modify the line, if the flag is set</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="ot">/^</span><span class="ss">writable = </span><span class="ot">/</span> <span class="op">{</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a>	<span class="cf">if</span> <span class="op">(</span>processing<span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a>	    <span class="kw">print</span> <span class="dt">$0</span><span class="st">&quot; foo&quot;</span><span class="op">;</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a>		skip <span class="op">=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a>	<span class="op">}</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="co"># Clear the section flag (as we're in a new section)</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a><span class="ot">/^\</span><span class="sc">[</span><span class="ot">$/</span> <span class="op">{</span></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a>	processing <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="co"># Output a line (that we didn't output above)</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a><span class="ot">/.*/</span> <span class="op">{</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a>	<span class="cf">if</span> <span class="op">(</span>skip<span class="op">)</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a>	    skip <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a>	<span class="cf">else</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a>		<span class="kw">print</span> <span class="dt">$0</span><span class="op">;</span></span>
<span id="cb2-30"><a href="#cb2-30" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>Easy!</p>]]></summary>
</entry>
<entry>
    <title>Interactive and Media Programming</title>
    <link href="https://passingcuriosity.com/2006/interactive-and-media-programming/" />
    <id>https://passingcuriosity.com/2006/interactive-and-media-programming/</id>
    <published>2006-06-27T00:00:00Z</published>
    <updated>2006-06-27T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>As I’ve mentioned a few times, I’m hoping to work on some materials for computer science education this semester. The gist of my current plans is a core of basic computer science material (very basic data structures and algorithms) backed up by a range of individual and small group projects. I hope to provide a wide enough range of projects to ensure that most students will find something engaging enough that they learn (even in spite of their wanting only to use the Internet).</p>
I’m currently anticipate designing projects using some, if not all, of the following pieces of software: <!--

-->
<dl>
<!--
    -->
<dt>
<a href="http://www.haskell.org/haskore/">Haskore</a>
</dt>
<!--
    -->
<dd>
A computer music system based on Haskell.
</dd>
<!--
    -->
<dt>
<a href="http://haskell.org/pan/">Pan</a> (or Pan# or one of the several variations on the theme)
</dt>
<!--
    -->
<dd>
A functional graphical processing language similar to Haskell.
</dd>
<!--
    -->
<dt>
<a href="http://www.cs.kent.ac.uk/projects/pivotal/">Pivotal</a>
</dt>
<!--
    -->
<dd>
A document centred presentation of Haskell.
</dd>
<!--
    -->
<dt>
<a href="http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/FunWorlds/">FunWorlds</a>
</dt>
<!--
    -->
<dd>
An interactive 3D animation package in, you guessed it, Haskell.
</dd>
<!--
-->
</dl>
<!--

-->
You may have noticed a trend in the projects above: they all use, or are closely related to, the <a href="http://www.haskell.org/">Haskell programming language</a>. This is for a number of reasons: <!--

-->
<ol>
<!--
    -->
<li>
I like functional programming, in general, and Haskell, in particular.
</li>
<!--
    -->
<li>
I don’t like the languages usually taught to students (Java, VisualBasic, etc.)
</li>
<!--
    -->
<li>
I think that a different, more fundamental, approach might help (supported, I think, by the experiences of teachers using SICP in high schools in the U.S.).
</li>
<!--
-->
</ol>
<!--

-->
<p>We’ll see how things pan out. If possible, I’d like to integrate some of the above packages into a single whole. <acronym>Haskore</acronym> and one of the portable Haskell variants of <acronym>Pan</acronym>, for example, might be integrated with <acronym>Pivotal</acronym> to give a relatively simple environment for interactive, multi-media <acronym>Haskell</acronym> programming. <acronym>Haskore</acronym>, in particular, could benefit extraordinarily from such an integration: the student be able to “code”, visualise and listen to their musical compositions from the same program.</p>]]></summary>
</entry>
<entry>
    <title>The Fun of Programming</title>
    <link href="https://passingcuriosity.com/2006/the-fun-of-programming/" />
    <id>https://passingcuriosity.com/2006/the-fun-of-programming/</id>
    <published>2006-05-05T00:00:00Z</published>
    <updated>2006-05-05T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>My copy of <a href="http://www.amazon.com/dp/0333992857/">The Fun of Programming</a> edited by Jeremy Gibbons and Oege de
Moor came in the other day and I’ve been looking through it. It has chapters
covering a wide range of topics:</p>
<ol type="1">
<li><p>functional data-structures, amortised analysis, etc.;</p></li>
<li><p>testing and specification with QuickCheck;</p></li>
<li><p>programming with folds, unfolds, etc.;</p></li>
<li><p>music programming;</p></li>
<li><p>representing financial contracts;</p></li>
<li><p>graphics programming;</p></li>
<li><p>hardware description;</p></li>
<li><p>combinators;</p></li>
<li><p>arrows; and</p></li>
<li><p>phantom types</p></li>
</ol>
<p>amongst other topics. This looks to be a fascinating mixture of methods
(data-structures, testing, folds, arrows, etc.) and applications (music,
graphics, financial contacts, hardware description, logic programming, etc.) if
a little thin for its price.</p>
<p>Both the <a href="http://web.comlab.ox.ac.uk/oucl/publications/books/fop/">software from the book</a> and <a href="http://web.comlab.ox.ac.uk/oucl/research/pdt/ap/fop/">details about the symposium</a> from
which its content comes are available on the Oxford Computing Laboratory
web-site.</p>]]></summary>
</entry>
<entry>
    <title>The Teaching of Programming</title>
    <link href="https://passingcuriosity.com/2006/the-teaching-of-programming/" />
    <id>https://passingcuriosity.com/2006/the-teaching-of-programming/</id>
    <published>2006-04-20T00:00:00Z</published>
    <updated>2006-04-20T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Having decided that computer science isn’t really my thing (I prefer it
as a hobby, rather than a career), I’m <a href="http://interestingexperience.blogspot.com/2006/02/change-in-focus.html">now
training to be a teacher</a> and, as such, spend a certain amount of
time thinking about ways to present material. One of the topics that is
of no small interest to me is the teaching of programming, as distinct
from teaching programming languages.</p>
<p>I spent some of the 2.5 hour bus trip back from classes in Hobart today
thinking about ways to present <a href="http://en.wikipedia.org/wiki/Monads_in_functional_programming">monads</a>.
As a result, I’ve decided to write my very own version of that mainstay
of the Haskell community – Yet Another Monads Tutorial. The goals of
this project are twofold:</p>
<ol type="1">
<li><p>to try to solidify my understanding of monads, their uses and theory;
and</p></li>
<li><p>to present programming in a way that very few or, more likely, no
students will experience before advanced undergraduate CS classes.</p></li>
</ol>
<p>My current thinking is to introduce functional programming in terms of
expression reduction (using <a href="http://www.haskell.org/hugs/">Hugs</a> or, maybe, <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci.html">GHCi</a>).
This will segue into a discussion of evaluation semantics (specifically,
lazy evaluation) which will raise the problem of sequenced computations.
<code>Monad</code>s (as we already know) provide a solution to this problem which
will be demonstrated with some work in the <code>IO</code> monad. To really
understand how <code>Monad</code>s work in Haskell, we’ll have to take a brief
detour through type classes before we look at defining our own instances
of <code>Monad</code>.</p>
<p>The main example (and the only one that I’ve thought most about) will be
a <code>Monad</code> that allows us to compose transformation matrices for 3D work
in monadic style. In this <code>Monad</code>, we’ll be able to create a
transformation matrix by doing something like:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>myTransform <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>    identityMatrix;</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>    rotateAbout <span class="dt">Z</span> <span class="dv">90</span>;</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>    scale <span class="dt">X</span> <span class="fl">1.5</span>;</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>    translate <span class="dt">Y</span> <span class="dv">20</span></span></code></pre></div>
<p>rather than explicitly creating the matrix for each transformation and
multiplying them together or, worse, poking at the individual members of
the transformation matrix. Furthermore, this example lends itself quite
well to extension. Instead of calculating a matrix which performs the
appropriate transformations, we might instead create an data-structure
encoding the calculation which will, when evaluated, yield such a
matrix. This data-structure could then be evaluated (like, if I
understand correctly <a href="http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Control-Monad-ST.html#v%3ArunST">runST</a> does for the <code>ST</code> monad) or it could be
subjected to symbolic manipulation (perhaps allowing the students to
implement a simple optimiser).</p>
<p>This will probably turn into my major project for next semester
(developing plans and materials for an entire unit). If it does, I’ll
probably make it available online somewhere.</p>]]></summary>
</entry>
<entry>
    <title>Integrating support for undo with exception handling</title>
    <link href="https://passingcuriosity.com/2006/integrating-support-for-undo-with-exception-handling/" />
    <id>https://passingcuriosity.com/2006/integrating-support-for-undo-with-exception-handling/</id>
    <published>2006-04-20T00:00:00Z</published>
    <updated>2006-04-20T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p><a class="title" href="http://research.microsoft.com/research/pubs/view.aspx?tr_id=845">Integrating support for undo with exception handling</a> by Avraham Shinnar; David Tarditi; Mark Plesko and Bjarne Steensgaard.</p>
<p>This paper appears to have as its object a solution to similar problems
as those addressed by software transactional memory, i.e. maintaining
memory consistency. Where <acronym title="software transactional
memory">STM</acronym> provides transactions that can be used to
implement multi-threaded programmes much more simply that traditional
explicit locking approaches, this paper uses a similar mechanism to
handle unexpected failures (uncaught exceptions) and roll-back the
effects of the failed code.</p>
<p>The authors describe their implementation of an undo mechanism in
Bartok, an experimental optimising <acronym title="C-Sharp">C#</acronym>
compiler and <acronym title="Common Language Runtime">CIL</acronym>
runtime. Their system extends <acronym title="C-Sharp">C#</acronym> with
a <code>try_all</code> block which acts as a catch-all exception
handler. If an exception propagates is raised within a
<code>try_all</code> block and is not handled before it reaches the
scope of the block, then the roll-back mechanism is engaged.</p>
<p>The main difference between Haskell’s <acronym title="software
transactional memory">STM</acronym> is the goal: where <acronym title="software transactional memory">STM</acronym> is concerned with
maintaining memory consistency in the face of concurrently executing
threads, this system is concerned with simplifying error handling and
recovery.</p>
<p><a href="http://scholar.google.com/scholar?hl=en&lr=&safe=off&cluster=14653294056375713537">Google</a> |
<a href="http://www.citeulike.org/article/556290">CiteULike</a> |
<a href="http://lambda-the-ultimate.org/node/446">LtU</a></p>]]></summary>
</entry>

</feed>
