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] |
Lauri Alanko <la@la.iki.fi> writes: > 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? In Guile the behaviour is that calling a continuation captured in the before guard will cause both the main thunk and the after guard to be called. > 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? Yes, it's always safe to throw exceptions from within the before guard. Note that this is an entirely different question than the question of calling a captured continuation. In Guile, exceptions don't return. Instead control is left to the innermost exception handler (for the particular type of exception) in the dynamic context of the throw. The dynamic context of the after or before guards is the same as the dynamic context of the surrounding code. /mdj