[previous] [up] [next]     [contents] [index]
Next: Primitive Exceptions Up: Exceptions and Control Flow Previous: Exceptions and Control Flow

Exceptions

MzScheme supports the exception system proposed by Friedman, Haynes, and Dybvig.[footnote] MzScheme's implementation extends that proposal by defining the specific exception values that are raised by each primitive error.

The following example defines a divide procedure that returns +inf.0 when dividing by zero instead of signalling an exception (other exceptions raised by / are signalled):

  (define div-w-inf
    (lambda (n d)
      (with-handlers ([exn:application:math:zero? 
                       (lambda (exn) +inf.0)])
        (/ n d))))




[previous] [up] [next]     [contents] [index]
Next: Primitive Exceptions Up: Exceptions and Control Flow Previous: Exceptions and Control Flow

PLT