Changeset 7245 in project


Ignore:
Timestamp:
01/02/08 19:55:49 (12 years ago)
Author:
svnwiki
Message:

Changes applied for ben (12.15.146.254) through svnwiki:

More reformatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/srfi-34

    r7244 r7245  
    133133* syntax-case
    134134
    135 === Usage
    136 (require-extension srfi-34)
    137 
    138 === Download
    139 srfi-34.egg
    140 
    141135=== Documentation
    142136
     
    147141The module maintains a list of exception handlers using dynamic-wind. It defines the default exception handler which aborts execution of the whole program, thusly:
    148142
     143<enscript highlight="scheme">
    149144(define *current-exception-handlers*
    150145  (list (lambda (condition)
    151146          (error "unhandled exception" condition))))
     147</enscript>
    152148
    153 A naked call to raise would end up calling this handler, aborting the program.
    154 procedure: (raise OBJ)
     149A naked call to '''raise''' would end up calling this handler, aborting the program.
    155150
    156     Raise an exception. OBJ can be any scheme object. Invokes the 'current exception handler' thunk, which is the car of the *current-exception-handlers* list. This handler thunk handles the exception OBJ.
     151'''procedure: (raise OBJ)'''
    157152
    158     The handler thunk should then either call error to stop program execution, or it should have stored the continuation at which to resume execution of the program after handling the exception, and pass it's result to that continuation where the program's flow of execution will resume.
     153Raise an exception. OBJ can be any scheme object. Invokes the 'current exception handler' thunk, which is the car of the *current-exception-handlers* list. This handler thunk handles the exception OBJ.
    159154
    160     Installing an exception handler that returns will cause the raise procedure to abort the program by call error, alerting that the exception handler thunk erroneously returned control to the raise procedure instead of to a different continuation as it should.
     155The handler thunk should then either call error to stop program execution, or it should have stored the continuation at which to resume execution of the program after handling the exception, and pass it's result to that continuation where the program's flow of execution will resume.
    161156
    162 macro: (guard (VAR CLAUSE1 CLAUSE2 ...) BODY )
     157Installing an exception handler that returns will cause the raise procedure to abort the program by call error, alerting that the exception handler thunk erroneously returned control to the raise procedure instead of to a different continuation as it should.
    163158
    164     Syntax: Each clause should have the same form as a cond clause.
     159'''macro: (guard (VAR CLAUSE1 CLAUSE2 ...) BODY )'''
    165160
    166     Semantics: Whereas raise is analogous to the throw commonly found in other languages, guard is analogous to the try/catch syntax often implemented. VAR gets bound to the exception thrown by BODY, and then the CLAUSEs which have access to VAR, are evaluated until one of the tests succeeds, and the corresponding code gets run. As with cond, the else test always succeeds and so can be used to handle general exceptions.
     161Syntax: Each clause should have the same form as a cond clause.
    167162
    168     Notes: guard also supports => in the clauses. If the test returns a useful value, then => can be used to specify a procedure to apply to that value in that case. See the examples section and the srfi for clarification on this.
     163Semantics: Whereas raise is analogous to the throw commonly found in other languages, guard is analogous to the try/catch syntax often implemented. VAR gets bound to the exception thrown by BODY, and then the CLAUSEs which have access to VAR, are evaluated until one of the tests succeeds, and the corresponding code gets run. As with cond, the else test always succeeds and so can be used to handle general exceptions.
    169164
    170 procedure: (with-exception-handler HANDLER THUNK)
     165Notes: guard also supports => in the clauses. If the test returns a useful value, then => can be used to specify a procedure to apply to that value in that case. See the examples section and the srfi for clarification on this.
    171166
    172     Returns the result(s) of invoking thunk. Handler must be a procedure that accepts one argument. It is installed as the current exception handler for the dynamic extent (as determined by dynamic-wind) of the invocation of thunk.
     167'''procedure: (with-exception-handler HANDLER THUNK)'''
     168
     169Returns the result(s) of invoking thunk. Handler must be a procedure that accepts one argument. It is installed as the current exception handler for the dynamic extent (as determined by dynamic-wind) of the invocation of thunk.
    173170
    174171=== Version
    175172
    176     * 0.1 Initial release
     173* 0.1 Initial release
Note: See TracChangeset for help on using the changeset viewer.