To answer my own question, I've now got a glimmer as to how to do most of this, using syntax-case and quasi-syntax, as described in https://www.gnu.org/software/guile/manual/html_node/Syntax-Case.html#Syntax-Case with the display-compile-timestamp example, and then cleverly reworking that. ...Basically, replacing the (current-time) in that example, with the memoization code, thus providing compile-time memoization. I'll post when I get something working-ish. Tomorrow-ish.
Now all I need is a way to tell apart `42` from `(+ x y)` ... --linas