Automatic function memoization with macro-magic