Monthly Archives: July 2013


Last time, I spoke about lambdas, and left you with this comment about other features of lambdas. One that’s particularly worth bearing in mind is the ability to pass this as a lambda parameter. That means you can get access to more than just the enclosing scope variables, you can get access to the enclosing […]

Posted in FussyLogic | Tagged , , , | Leave a comment

La Lambda

Let’s say we’ve loaded a database table into memory and now we want to do some work with it. I’m imagining a case where we’ve selected a small subset of records from an enormous table (i.e. it wasn’t cheap to fetch) and we want to pull records that meet particular conditions from our subset. Let’s say […]

Posted in FussyLogic | Tagged , , , | Leave a comment


Let’s say we are reading tagged blocks from within some sort of packet. The blocks being tagged means we won’t care whether they’re present, what order they come in, and can have each tag be a different length. <tag2> <tag2_data0> <tag2_data1> … <tag2_data11> <tag1> <tag1_data0> <tag1_data1> … <tag1_data8> <tag6> <tag6_data0> <tag6_data1> … <tag6_data20> <tag3> <tag3_data0> […]

Posted in FussyLogic | Tagged , , | Leave a comment


Consider this: #include <iostream> using namespace std; int x = 10; int f(int& x) { x++; return x; } void g(int& x) { x *= 2; return x; } int h(int f, int g) { return f + g; } int main() { clog << "h() = " << h(f(x), g(x)) << endl; return 0; […]

Posted in FussyLogic | Tagged , | Leave a comment

Don’t Take Exception

Exceptions were an enormous improvement for error handling in software. Previously we would have code like this: int a() { if( !do_something() ) return error_code_for_a; return success_for_a; } int b() { if( a() == error_code_for_a ) return error_code_for_b; return success_for_b; } int c() { if( b() == error_code_for_b ) return error_code_for_c; return success_for_c; } int […]

Posted in FussyLogic | Tagged , , | Leave a comment

Android Content Providers and Synchronisation

Last time we looked at creating accounts for our own custom purposes on an Android device. Now we’ve got an account, we’d like to do something with it. This series of articles will cover using an account to regularly synchronise some state on an upstream server with state held on the Android device. Implementing synchronisation […]

Posted in FussyLogic | Tagged , , , , | Leave a comment

Recursive SQL Query

Imagine these tables (I’m using PostgreSQL): CREATE Capabilities ( ID serial PRIMARY KEY, Code text NOT NULL ); CREATE CapabilityPermissions ( ID serial PRIMARY KEY, CapabilitityID integer NOT NULL REFERENCES Capabilities(ID), PermissionID integer NOT NULL REFERENCES Capabilities(ID) ); What I’m aiming for here is the ability to make a permissions hierarchy. This will let us […]

Posted in FussyLogic | Tagged , , | Leave a comment

Interfaces in C++

C++ has no such thing as an interface. It’s one of the few Java vs C++ comparisons that I think Java wins. Interfaces are useful. I’d like to talk about how we can get similar functionality into C++. First we need to define our terms. Here’s an abstract base class in C++. class Shape : […]

Posted in FussyLogic | Tagged , , , , , | Leave a comment

Garbage Collection is Harmful

I don’t like garbage collection. Fundamentally, my problem with languages that have a garbage collected memory model is this: memory is not the only resource. Resource Acquisiation is Initialisation. RAII as it’s often abbreviated to. RAII and object oriented languages go together beautifully because the language does the heavy lifting with its automatic calling of […]

Posted in FussyLogic | Tagged , , , | Leave a comment

Finally, No

Why doesn’t C++ have a finally block? Here’s some Java. void userFunction() { f = new Resource();; try { // might throw buffer =; } finally { f.close(); } useBuffer(buffer); } It’s tempting, after you’ve had a finally for a while to think that it’s necessary for proper resource management in the face […]

Posted in FussyLogic | Tagged , | Leave a comment