On Mon, 23 Dec 2013 15:20:32 -0500 Matthias Felleisen <[email protected]> wrote:
> > For that, you will need to wrap the whole loop because > (in-directory ...) fails, and no, I don't know how to resume this > optimized loop: > > #lang racket ;; foo.rkt > > (define start-dir ".") > > ;; > (with-handlers (((lambda (x) #t) (lambda (e) (log-warning > "in-directory failed")))) (for ([f (in-directory start-dir)] #:when > (regexp-match #rx"\\.rkt" f)) (with-handlers ((exn:fail:contract? > (lambda (e) (log-warning (exn-message e)))) (exn? displayln)) > (displayln (path->string f))))) > > Yes, I get the message in-directory failed now. However, if there is no way to resume a failure of in-directory then the function isn't usable. It is a "Schönwetter-Funktion" I would say in German. Then I need to build my own 'in-directory' by using directory-list and checking permissions which isn't really efficient. BTW, I saw also 'call-with-exception-handler'. Is it more capable than 'with-handlers'? -- Manfred > > On Dec 23, 2013, at 3:06 PM, Manfred Lotz > <[email protected]> wrote: > > > #lang racket ;; foo.rkt > > > > (define start-dir "/tmp/testdir") > > > > (for ([f (in-directory start-dir)] #:when (regexp-match #rx"\\.rkt" > > f)) (with-handlers ((exn:fail:contract? (lambda (e) (log-warning > > (exn-message e))))) > > (displayln (path->string f)))) > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users

