[racket-dev] Speeding up `in-directory`

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Sep 4 15:23:06 EDT 2013

At Wed, 4 Sep 2013 15:13:31 -0400, Sam Tobin-Hochstadt wrote:
> On Wed, Sep 4, 2013 at 12:29 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> >
> >                                  (directory-list
> >                                   (path->complete-path d init-dir)))])
> I'm pretty sure this is wrong, but I'm not sure how to fix it.  In
> particular, there's no reason that `init-dir` should have any relation
> to any of the paths being generated, and so using it here is wrong.
> You can break the code with
> (for ([i (in-directory6 d)])
>   (current-directory "/")
>   (displayln i))
> when run with a non-#f value of d.

I think that if `d` is a relative path then it should be treated as
relative to the current directory at the time that `in-directory6` is

 * When I use "/home/mflatt/tmp" for `d`, I get a listing of files
   under "/home/mflatt/tmp".

 * When I use "tmp" and my initial directory is "/home/mflatt", I still
   get a listing of files under "/home/mflatt/tmp".

Both of those are as they should be, I think.

When I use `in-directory` instead of `in-directory6`, then it behaves
in a way that I think is less useful and should count as a bug in

Posted on the dev mailing list.