This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hello again. In r5rs it says "The effect of using a captured continuation to enter or exit the dynamic extent of a call to before or after is undefined." What exactly is this undefined behavior with guile? Can I trust that if I exit the before guard with a continuation or an exception, then the main thunk will not be called? This seems to be the case, but I just wanted to make sure.. What I'm trying to do is basically: (dynamic-wind get-resource-a (lambda () (dynamic-wind get-resource-b do-stuff free-resource-b)) free-resource-a) Now if something fails in do-stuff, an exception will occur that is caught above this, and the resources will be freed. But if getting a resource fails, can I just throw an exception inside the before guard, and trust it will always work properly and not call the main thunk or after guard in that case? Otherwise I'd have to check both in the main thunk and the after guard whether the resource has actually been allocated, which is a bit cumbersome in the long run. Or is there perhaps a better way to do this sort of thing? In C++, say, you could just do: {Resource a=get_resource_a(); Resource b=get_resource_b(); do_stuff(a,b);} and then the destructors would take care of freeing them when exiting the scope.. Thanks for any suggestions. Lauri Alanko la@iki.fi