[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
16.3 Deprecated try form
- bigloo syntax: try exp handler
-
This form is deprecated. As much as possible, it should be replaced with true exceptions (i.e.,
with-exception-handler
andraise
). The argument exp is evaluated. If an error is raised, the handler is called. The argument handler is a procedure of four arguments. Its first argument is the continuation of try. The other arguments are proc, mes and obj. Invoking the first argument will resume after the error.(let ((handler (lambda (escape proc mes obj) (print "***ERROR:" proc ":" mes " -- " obj) (escape #f)))) (try (car 1) handler)) -| ***ERROR:CAR:not a pair -- 1 ⇒ #f
The argument handler is not evaluated in the dynamic scope of its
try
form. That is:(let ((handler (lambda (escape proc mes obj) (escape (car obj))))) (try (car 1) handler)) error--> *** ERROR:bigloo:CAR Type `PAIR' expected, `BINT' provided -- 1
Some library functions exist to help in writing handlers:
- bigloo procedure: warning [arg]…
This form signals a warning. That is, is arg are displayed on the standard error port.
(define (foo l) (if (not (pair? l)) (begin (warning "foo:" "argument not a pair -- " l) '()) (car l))) (foo 4) -| *** WARNING:bigloo:foo: argument not a pair -- 4 ⇒ '()
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.