Non-local returns and compound statements

Smalltalk uses closures all over the place. They’re how control structures are built up, for starters. They replace what compound statements do in other languages. So let’s look at a simple function in C:

Repository crawlers for Mercurial (or why you need to learn about revsets)

Recently I needed to write a tool to crawl a Mercurial repository and look for certain things in unfinished branches that could cause us problems in the future. Given I knew that Mercurial was written in Python, my first approach to this was to start digging around in its code and see if there was…

Squeezing the F# zipper into a Monad

Not being entirely happy with my F# zipper implementation throwing exceptions I decided to investigate whether I could use option types to replace the exceptions thrown when you try to navigate off the tree – for example trying to move up when you are at the top of the tree or move down when you…

“Try again” with Exceptions

Like many modern languages, Smalltalk has the concept of an exception. When an exception’s signalled, the current stack of contexts – activation frames – is gradually unwound (with unwind blocks – what in Delphi would be called try-finally blocks – being executed at each stage), until a context handles that particular exception. If no context…