I think the key question is what you want to happen if you would need
to re-run the "pre" thunk, because you re-enter the code via a
continuation.
In many cases, you don't want to support that at all, and then it's
pretty easy (although you still need mutation):
(let* ([conn (connect-to-server)]
[started? #f])
(dynamic-wind
(lambda () (when started? (error 'fail)) (set! started? #t))
(lambda () (send-message conn "hi"))
(lambda () (finalize-connection conn))))
You could just not do the check in the pre thunk, in which case you'd
get worse error messages but probably nothing else wrong.
Sam
> To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/CAE8gKofbcigfJDFgU8AXVqomQYqmgGT_OEXwAx7m8BQyyoCHqQ%40mail.gmail.com.