[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exceptions




>
>   (with-handlers ([exn:application?
>                    (lambda (exn)
>                      (exn:application-value exn))])
>     (bomber 4))
>   ==>
>   0
>
> You can simplify the above code to
>
>   (with-handlers ([exn:application?
>                    exn:application-value])
>     (bomber 4))
>   ==>
>   0
>
> which shows that you don't always need to write (lambda (exn) ...).

Thanks again to everyone for their help with my understanding of exceptions
in mzscheme. I'm well and truly underway, and I've worked out the
differences b/n the defnitions and the interactions windows!

In the code above, the last example

(with-handlers ([exn:application?
                 exn:application-value])
 (bomber 4))
 ==>
 0

exn:application? is a built-in predicate that is applied to the exception
raised, and if the result is not-false, the handler is called. The handler
in this case looks to be exn:application-value - but this, I think, is a
structure accessor. I'm not sure how it "knows" which structure to access
the value slot of? (Is there a secret "$" in there, speaking of Perls and
Swine :-))

Thanks again

chris



Dr. Chris Wright
Director, ICU
Monash Medical Centre
Clayton VIC 3168 AUSTRALIA