Coming late to this ...
On 5/19/2021 11:31 AM, David Storrs wrote:
On Tue, May 18, 2021 at 4:09 PM Philip McGrath
mailto:phi...@philipmcgrath.com>> wrote:
On Tue, May 18, 2021 at 3:52 PM Sam Tobin-Hochstadt
mailto:sa...@cs.indiana.edu>> wrote:
I think the key question is what
On Tue, May 18, 2021 at 4:09 PM Philip McGrath
wrote:
> On Tue, May 18, 2021 at 3:52 PM Sam Tobin-Hochstadt
> wrote:
>
>> 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,
On Tue, May 18, 2021 at 3:52 PM Sam Tobin-Hochstadt
wrote:
> 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 …
>
Then you can use
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)]
Thank you. Is there a way to do it without the mutation? I was hoping to
use this for macro generation that simplifies combining with-handlers and
dynamic-wind with setup/teardown code.
(try [pre
(define db (connect-to-db))
(define conn (connect-to-server))]
[(send-message conn
It's not quite as convenient, but here's a version of your program
that should work:
(let ([conn #f])
(dynamic-wind
(lambda () (set! conn (connect-to-server))
(lambda () (send-message conn "foo"))
(lambda () (finalize-connection conn
Sam
On Tue, May 18, 2021 at 2:08 PM David
dynamic-wind is nice because it guarantees that the pre- and postconditions
for a chunk of code will be run regardless of continuation jumps,
exceptions, etc. The only issue I have is that the three thunks do not
share scope, making it difficult to do setup/teardown workflows. I feel
like I
7 matches
Mail list logo