[racket] try/catch/finally idiom in Racket

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Fri Oct 8 20:20:49 EDT 2010

Should "racket/base" include something like "unwind-protect"?

The documentation could warn about what this restricts.

I feel bad every time I use "dynamic-wind" to approximate 
"unwind-protect", pretending that I don't have first-order 
continuations.  But often I'm cleaning up one-shot external resources 
anyway.  "unwind-protect" would be more explicit about the assumptions 
than "dynamic-wind" would, and incidentally would be tidier in the code.

Jay McCarthy wrote at 10/08/2010 07:40 PM:
> I use dynamic-wind for this. If there is something better, I don't know what it is. dynamic-wind is a little bit funny though because if you capture continuations then the in/out handlers can run multiple times which might defy your expectations. You could set up a continuation barrier on the inside to ensure that doesn't happen though.


Posted on the users mailing list.