I've fixed some bugs in my own memoization hack. It should now perform as advertised. And, as Philipp pointed out, it can indeed be reduced to pure Lua using select.
I've also gone to the trouble of creating separate result caches for `func()` and `func(nil)`, which, I suppose, could sometimes be useful?