chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some questions about concurrency (mostly)


From: John Cowan
Subject: Re: Some questions about concurrency (mostly)
Date: Sat, 7 Nov 2020 20:02:12 -0500



On Sat, Nov 7, 2020 at 5:51 PM Chris Vine <vine35792468@gmail.com> wrote:
 
For my elucidation, why?  The indentation of the code isn't ideal but
the whole purpose of dynamic-wind is to handle code leaving the thunk in
case of exception, application of a continuation object or regular
return.

You're right about the second and third cases, but not the first.  Raising an exception *simply* calls the current exception handler, which is then free to return to the point of call like any other procedure.  In such a case, the after-thunk is not run, since dynamically you are still inside the main thunk.  This is a fundamental distinction between Lisp exceptions and every other language's exceptions.

Only if the exception handler uses call/cc to escape back to the dynamic context where the handler was set up is the after-thunk run.  This is done for you automatically if you use `handle-exceptions` or `chicken-case` or R7RS `guard`.

If you raise an exception with `abort` or `error`, then if the handler returns, another exception "unexpected return from handler" is raised.

Note also that when the thread scheduler switches to a new thread, any before- or after-thunks are not run, as the thread is supposed to be unaware that the switch happened.



John Cowan          http://vrici.lojban.org/~cowan        cowan@ccil.org
Would your name perchance be surname Puppet, given name Sock?
                --Rick Moen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]