Code to replace $[foo} in arbitrary strings with foo from a hash-table added by alaricsp on Sun Jun 26 22:23:18 2016
(define (interpolate location *vars* text)
(irregex-replace/all
(irregex '(seq "${" (=> expr (+ (~ ("}")))) "}"))
text
(lambda (m)
(let ((expr (irregex-match-substring m 'expr)))
(cond
((string=? expr "$")
"$")
((hash-table-exists? *vars* expr)
(hash-table-ref *vars* expr))
(else
(error (sprintf "Undefined variable ${~a} in ~a" expr location))))))))