I find myself doing stuff like this very often when writing tests using the test egg:
(test #f 1 (let ((res (- 2 1)))(set! data res) res))
I'd really prefer to do something like:
(test-and-define data #f 1 (- 2 1))
But the closest I could get was:
(define-syntax test-and-set
(syntax-rules ()
((_ name arg1 arg2 body ...)
(test arg1 arg2
(let ((res (begin body ...)))
(set! name res)
res
)))))
So I can do:
(define data #f)
(test-and-set data #f 1 (- 2 1))
Questions:
1. Is there a generally better way to test and gather the result for use in downstream tests?
2. Is there a way to write a macro that can create the toplevel binding?
--
--
Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.