#lang racket ; pattern for ; TRY ; CATCH ; RESUME (define testit (lambda (x y default) ; RESUME (call/cc (lambda (RESUME) ; when everything is finished we invoke RESUME (call/cc (lambda (THROW) ; the context around this is the catch ; TRY ; here is the body of the try, which computes result (let ((result ; compute the result in here, or throw (if (not (eq? 0 y)) (/ x y) (THROW)) )) ; it worked, so return result (RESUME result) ) ) ) ; CATCH ; what happens here is the catch, invoked only if we throw ; in this case we return the default value (display "Caught exception")(newline) (RESUME default) ) ) )) (testit 4 2 "div by 0") (testit 4 0 "div by 0")