(I can't be bothered to run his benchmarks)
#include <stdio.h> typedef struct env_ E; typedef struct fat_ptr_ Fp; typedef int fn(E*); struct fat_ptr_ { fn *f; E *e; }; #define INT(body) ({ int lambda(E*){ return body; }; (Fp){lambda,0}; }) struct env_ { int k; Fp xl; Fp x2; Fp x3; Fp x4; }; #define FpMk(fn,e) {fn, e} #define FpCall(fn) (fn.f(fn.e)) int main(){ int a(E env, Fp x5){ int b(E *ep){ return a( (E){--(ep->k), FpMk(b, ep), ep->xl, ep->x2, ep->x3}, ep->x4 ); } return env.k<=0 ? FpCall(env.x4) + FpCall(x5) : b(&env); } printf(" %d\n", a( (E){10, INT(1), INT(-1), INT(-1), INT(1)}, INT(0)) ); }
(I can't be bothered to run his benchmarks)