previous up next     contents index
Next: Primitive Exceptions Up: Programming Constructs Previous: Regular Expressions

Exceptions

 

 

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

This 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: Programming Constructs Previous: Regular Expressions

PLT