[plt-scheme] thunk-failed? with exceptions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Jun 22 23:40:57 EDT 2002

> How can I implement Oleg's thunk-failed? procedure
> (below) in PLT that will return #t for things such as 
> 
> (thunk-failed? (lambda () (raise-syntax-error 'foo
> "bar")))

 (define (thunk-failed? t)
   (with-handlers ([(lambda (x) #t)   ; handle all exns
                    (lambda (x) #t)]) ; return #t 
      (t)
      #f)))

Matthew




Posted on the users mailing list.