Funky code

Today I had the opportunity to write some interesting code. We needed to, essentially, insert a hack into our system wherein one style of request had a slightly different style of processing.

So this is in Go. Functions are first-class objects.

I have a system that does things in parallel. Those things are specified by a pointer to a function. And now I needed to slightly fork a couple of those.

The function, let's call it DoStuff takes a slice of functions.

So I made another function, mutate, that takes one of the original functions, and wraps it in a closure.

Then it goes on in its life as before.

Thinking of functions as objects is such a cool thing.

It can be tricky if you're not expecting it.

But it also shows off how a good design can be modified in interesting ways.

Previous
Previous

Country sunset

Next
Next

Reading