Of course, I can't help thinking of Greenspun's Tenth Rule when I see this sort of thing.<p>That said, my day job is C programming, and I am of course a heavy user of function pointers (how else can you get anything interesting done in C?). But C's type system does tend to get in the way, so you end up casting all pointers to void*, and things like that, just to shut the compiler up. Some Lisp-style macros would certainly help with this!
This seems to be kinda missing the point. Yes, you can do functional programming in almost anything that supports recursion and function indirection. But the essence of functional programming is <i>not</i> simply using a function pointer for everything. Those "if and switch statements" are perfectly functional concepts. It's the avoidance of side effects that generally distinguishes "functional" idioms from imperative ones.
Functional? If anything this is a poor man's OO, simulating a vtable. Even if it is using higher-order functions, that seems like a more accurate analogy.
Lots of the plan9 code is written in a style like this but with enums<p>A bit tricky to find the best example on my phone while on the bus but here's a flavour, the in-memory file system<p><a href="http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/ramfs.c" rel="nofollow">http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/ramfs.c</a><p>Edit : can anyone see how to add a comment to the article, I wanted to share the above info with him but comments don't seem open to me now I'm at my desk.<p>The plan9 way uses an interface style, the sort that is made explicit in Go :<p>from <a href="http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/nntpfs.c" rel="nofollow">http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/nntpfs....</a><p><pre><code> Srv nntpsrv = {
.destroyfid= fsdestroyfid,
.attach= fsattach,
.clone= fsclone,
.walk1= fswalk1,
.open= fsopen,
.read= fsread,
.write= fswrite,
.stat= fsstat,
};
</code></pre>
These file systems all run in user mode btw (as can all the disk based ones). Mycrotiv has even done a kernel with a built in rc shell that you attach your file systems after booting as yourself - a disk failure will not take down your system!