Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

By unwinding I mean performing registered clean-ups associated with dynamic controus (e.g. such as that set up by unwind-protect), whose effect is understood to be permanent, on the hypothesis that the contexts being abandoned cannot be returned to.

Scheme's dynamic-wind is a kind of academic attempt to repair uwinding for situations when contexts can be returned to.

It doesn't pass my smell test. If we are following a control flow that leaves a context in such a way that there is a possibility to resume there, we should simply. not touch anything.

On this topic, I didn't mention dynamically scoped variables. Continuations capture their dynamic context. So that is to say, suppose *print-base* is set to 16 for printing integers in hex. Or ruppose *stdout* is redirected to a file. What happens if we capture a delimited continuation, and then resume it? Part of the resumption will be the reinstatement of the dynamic scope, so those variables are effectively captured. And I think that the capture of the dynamic scope goes beyond the prompt; i.e. it doesn't obey the delimiting, which is probably the least surprising requirement.

> That's essentially what lone is doing.

So that is good and you can think of unwinding (e.g. in an exception-related permanent control transfer) as separate from that.



> By unwinding I mean performing registered clean-ups

I understand now. By unwinding I meant simply moving the stack pointer backwards. I never considered that the word could carry more meaning than that.

> If we are following a control flow that leaves a context in such a way that there is a possibility to resume there, we should simply. not touch anything.

Agreed. The dynamic-wind situation seems somewhat insane. I hope to avoid it altogether.

This weekend I'm planning to work on more control flow primitives, including a lightweight exception mechanism which doesn't capture the continuation. I think a finally/ensure function will be useful for cleanup in the case of non-resumable exceptions.

> dynamically scoped variables

My language doesn't have them. It's very much like Scheme with its nested environments.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: