Changeset 17938 in project


Ignore:
Timestamp:
04/26/10 20:59:44 (9 years ago)
Author:
zbigniew
Message:

man/4: Add Exceptions manual page

Location:
wiki/man/4
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • wiki/man/4/Parameters

    r17849 r17938  
    175175abort the current computation and to restart the read-eval-print loop.
    176176
    177 ---
    178 Previous: [[Declarations]]
    179 
    180 Next: [[Unit library]]
     177----
     178Previous: [[Declarations]] Next: [[Exceptions]]
  • wiki/man/4/Supported language

    r16559 r17938  
    1111* [[Declarations]]
    1212* [[Parameters]]
     13* [[Exceptions]]
    1314* [[Unit library]] Basic Scheme definitions
    1415* [[Unit eval]] Evaluation
  • wiki/man/4/Unit library

    r17856 r17938  
    394394
    395395
    396 
    397 
    398 
    399 === Exceptions
    400 
    401 
    402 CHICKEN implements the (currently withdrawn)
    403 [[http://srfi.schemers.org/srfi-12/srfi-12.html|SRFI-12]] exception system. For
    404 more information, see the
    405 [[http://srfi.schemers.org/srfi-12/srfi-12.html|SRFI-12]] document.
    406 
    407 
    408 
    409 ==== condition-case
    410 
    411 <macro>(condition-case EXPRESSION CLAUSE ...)</macro>
    412 
    413 Evaluates {{EXPRESSION}} and handles any exceptions that are covered by
    414 {{CLAUSE ...}}, where {{CLAUSE}} should be of the following form:
    415 
    416 <enscript highlight=scheme>
    417 CLAUSE = ([VARIABLE] (KIND ...) BODY ...)
    418 </enscript>
    419 
    420 If provided, {{VARIABLE}} will be bound to the signaled exception
    421 object. {{BODY ...}} is executed when the exception is a property-
    422 or composite condition with the kinds given {{KIND ...}} (unevaluated).
    423 If no clause applies, the exception is re-signaled in the same dynamic
    424 context as the {{condition-case}} form.
    425 
    426 <enscript highlight=scheme>
    427 (define (check thunk)
    428   (condition-case (thunk)
    429     [(exn file) (print "file error")]
    430     [(exn) (print "other error")]
    431     [var () (print "something else")] ) )
    432 
    433 (check (lambda () (open-input-file "")))   ; -> "file error"
    434 (check (lambda () some-unbound-variable))  ; -> "othererror"
    435 (check (lambda () (signal 99)))            ; -> "something else"
    436 
    437 (condition-case some-unbound-variable
    438   [(exn file) (print "ignored")] )      ; -> signals error
    439 
    440 </enscript>
    441 
    442 
    443 ==== get-condition-property
    444 
    445 <procedure>(get-condition-property CONDITION KIND PROPERTY [DEFAULT])</procedure>
    446 
    447 A slightly more convenient condition property accessor, equivalent to
    448 
    449   ((condition-property-accessor KIND PROPERTY [DEFAULT]) CONDITION)
    450 
    451 
    452 ==== System conditions
    453 
    454 All error-conditions signaled by the system are of kind {{exn}}.
    455 The following composite conditions are additionally defined:
    456 
    457 <table>
    458 
    459 <tr><td> (exn arity) </td><td>
    460 
    461 Signaled when a procedure is called with the wrong number of arguments.
    462 
    463 </td></tr><tr><td> (exn type) </td><td>
    464 
    465 Signaled on type-mismatch errors, for example when an argument of the wrong
    466 type is passed to a built-in procedure.
    467 
    468 </td></tr><tr><td> (exn arithmetic) </td><td>
    469 
    470 Signaled on arithmetic errors, like division by zero.
    471 
    472 </td></tr><tr><td> (exn i/o) </td><td>
    473 
    474 Signaled on input/output errors.
    475 
    476 </td></tr><tr><td> (exn i/o file) </td><td>
    477 
    478 Signaled on file-related errors.
    479 
    480 </td></tr><tr><td> (exn i/o net) </td><td>
    481 
    482 Signaled on network errors.
    483 
    484 </td></tr><tr><td> (exn bounds) </td><td>
    485 
    486 Signaled on errors caused by accessing non-existent elements of a collection.
    487 
    488 </td></tr><tr><td> (exn runtime) </td><td>
    489 
    490 Signaled on low-level runtime-system error-situations.
    491 
    492 </td></tr><tr><td> (exn runtime limit) </td><td>
    493 
    494 Signaled when an internal limit is exceeded (like running out of memory).
    495 
    496 </td></tr><tr><td> (exn match) </td><td>
    497 
    498 Signaled on errors raised by failed matches (see the section on {{match}}).
    499 
    500 </td></tr><tr><td> (exn syntax) </td><td>
    501 
    502 Signaled on syntax errors.
    503 
    504 </td></tr>
    505 
    506 </table>
    507 
    508 Notes:
    509 
    510 * All error-exceptions (of the kind {{exn}}) are non-continuable.
    511 
    512 * Error-exceptions of the {{exn}} kind have additional {{arguments}} and
    513 {{location}} properties that contain the arguments passed to the
    514 exception-handler and the name of the procedure where the error occurred (if
    515 available).
    516 
    517 * When the {{posix}} unit is available and used, then a user-interrupt
    518 ({{signal/int}}) signals an exception of the kind {{user-interrupt}}.
    519 
    520 * the procedure {{condition-property-accessor}} accepts an optional third
    521 argument. If the condition does not have a value for the desired property and
    522 if the optional argument is given, no error is signaled and the accessor
    523 returns the third argument.
    524 
    525 
    526 
    527396=== Environment information and system interface
    528 
    529 
    530397
    531398==== argv
     
    12671134one element.
    12681135
    1269 ---
    1270 Previous: [[Parameters]]
    1271 
    1272 Next: [[Unit eval]]
     1136----
     1137Previous: [[Exceptions]] Next: [[Unit eval]]
Note: See TracChangeset for help on using the changeset viewer.