| While working on implementing this feature for the Arcueid interpreter, it astounded me just how messy protect made the once-elegant ccc, on-err, and err functions. I basically had to take note of all functions registered by protect on the continuations that used them, and then stacked up these functions for execution whenever a continuation was called or an exception was raised, and doing this basically tripled the number of lines of code needed to implement ccc and exceptions, and I'm left with the feeling that there must be a better way to implement it. Googling implementations for dynamic-wind (which is basically what Arc's protect is all about) comes up with links to something called the Hanson-Lamping algorithm, which appears to be only vaguely referenced as an unpublished manuscript. There's a brief appendix that purports to describe the algorithm in an edition of the Scheme48 manual: http://www.cs.hmc.edu/~fleck/envision/scheme48/meeting/node7.html but the code does not actually execute either the before or after thunks under any circumstances of code execution if I understand the code correctly, and the explanation given is extremely sketchy, at least to me. It's certainly not enough for me to understand the algorithm well enough to be able to implement it. I'd like to see a proper explanation of the ideas behind this algorithm, or other alternative algorithms for implementing dynamic-wind with call/cc and exception primitives that are otherwise unaware of it. |