A dynamic root is a root frame of Scheme evaluation. The top-level repl, for example, is an instance of a dynamic root.
Each dynamic root has its own chain of dynamic-wind information. Each has its own set of continuations, jump-buffers, and pending CATCH statements which are inaccessible from the dynamic scope of any other dynamic root.
In a thread-based system, each thread has its own dynamic root. Therefore, continuations created by one thread may not be invoked by another.
Even in a single-threaded system, it is sometimes useful to create a new dynamic root. For example, if you want to apply a procedure, but to not allow that procedure to capture the current continuation, calling the procedure under a new dynamic root will do the job.
If an error occurs during evaluation, apply handler to the
arguments to the throw, just as
throw would. If this happens,
handler is called outside the scope of the new root -- it is
called in the same dynamic context in which
call-with-dynamic-root was evaluated.
If thunk captures a continuation, the continuation is rooted at
the call to thunk. In particular, the call to
call-with-dynamic-root is not captured. Therefore,
call-with-dynamic-root always returns at most one time.
Before calling thunk, the dynamic-wind chain is un-wound back to the root and a new chain started for thunk. Therefore, this call may not do what you expect:
;; Almost certainly a bug: (with-output-to-port some-port (lambda () (call-with-dynamic-root (lambda () (display 'fnord) (newline)) (lambda (errcode) errcode))))
The problem is, on what port will `fnord\n' be displayed? You
might expect that because of the
it will be displayed on the port bound to
some-port. But it
probably won't -- before evaluating the thunk, dynamic winds are
unwound, including those created by
So, the standard output port will have been re-set to its default value
display is evaluated.
(This function was added to Guile mostly to help calls to functions in C libraries that can not tolerate non-local exits or calls that return multiple times. If such functions call back to the interpreter, it should be under a new dynamic root.)
These objects are only useful for comparison using
They are currently represented as numbers, but your code should
in no way depend on this.
If integer exit_val is specified and if Guile is being used stand-alone and if quit is called from the initial dynamic-root, exit_val becomes the exit status of the Guile process and the process exits.
When Guile is run interactively, errors are caught from within the
read-eval-print loop. An error message will be printed and
called. A default set of signal handlers is installed, e.g., to allow
user interrupt of the interpreter.
It is possible to switch to a "batch mode", in which the interpreter will terminate after an error and in which all signals cause their default actions. Switching to batch mode causes any handlers installed from Scheme code to be removed. An example of where this is useful is after forking a new process intended to run non-interactively.
#fcase has not been implemented.
Go to the first, previous, next, last section, table of contents.