[racket] Handling errors from in-directory - and handling errors more generally

From: Peter Kiggins (peterk at palinurus.org)
Date: Thu Oct 14 06:15:24 EDT 2010

On 12 October 2010 16:50, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Tue, 12 Oct 2010 14:48:49 +0100, Peter Kiggins wrote:
>> [I am completely new to both Scheme and racket, so if my questions are
>> Looking at traversal of a file tree led me to in-directory.
>>
>> [ ... ]
>>
> No particular restart system built into the exception system. Code that
> raises an exception can include a continuation in the exception to
> allow a restart, and the exception raised for an asynchronous break
> (which is usually triggered when you hit Ctl-C) does that. But

I'm not doing well understanding the Racket exceptions/continuations
model!  I'll go read some more...

...some very elementary examples of using continuations (and
exceptions) would be very helpful...?

> `directory-list' as used by `in-directory' doesn't include a restart
> continuation in the exception record that it creates, and
> `in-directory' doesn't particularly catch exceptions or introduce any
> restart continuations.

I think 'in-directory' doesn't do what I want.  I'm struggling to see how it is
useful in practice if it barfs on errors and can't be re-started or told
how to handle errors?

> Among Racket procedures that support specific failure handling, most do
> so through an optional failure-thunk argument. For example, `hash-ref'
> and `file-or-directory-modify-seconds' accept failure thunks. The
> handlers in those cases just produce an alternate result --- the same
> thing could be accomplished by catching an exception --- as opposed to
> continuing internally. So, I think there's not really much precedent
> for this in the Racket API.

So standard idiom is optional arg for failure-thunk? And a re-start would
require that the procedure had provided one or more continuations to
explicitly handle re-starts?

Peter


Posted on the users mailing list.