DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Exceptions

Info Catalog (guile.info.gz) Multiple Values (guile.info.gz) Control Mechanisms (guile.info.gz) Error Reporting
 
 26.7 Exceptions
 ===============
 
 A common requirement in applications is to want to jump "non-locally"
 from the depths of a computation back to, say, the application's main
 processing loop.  Usually, the place that is the target of the jump is
 somewhere in the calling stack of procedures that called the procedure
 that wants to jump back.  For example, typical logic for a key press
 driven application might look something like this:
 
      main-loop:
        read the next key press and call dispatch-key
 
      dispatch-key:
        lookup the key in a keymap and call an appropriate procedure,
        say find-file
 
      find-file:
        interactively read the required file name, then call
        find-specified-file
 
      find-specified-file:
        check whether file exists; if not, jump back to main-loop
        ...
 
    The jump back to `main-loop' could be achieved by returning through
 the stack one procedure at a time, using the return value of each
 procedure to indicate the error condition, but Guile (like most modern
 programming languages) provides an additional mechanism called
 "exception handling" that can be used to implement such jumps much more
 conveniently.
 

Menu

 
* Exception Terminology       Different ways to say the same thing.
* Catch                       Setting up to catch exceptions.
* Throw                       Throwing an exception.
* Lazy Catch                  Catch without unwinding the stack.
* Exception Implementation    How Guile implements exceptions.
 
Info Catalog (guile.info.gz) Multiple Values (guile.info.gz) Control Mechanisms (guile.info.gz) Error Reporting
automatically generated byinfo2html