Re: CWD and other unresolved issues Marc Feeley 07 Feb 2020 20:14 UTC

> On Feb 7, 2020, at 1:04 PM, John Cowan <xxxxxx@ccil.org> wrote:
>
> Well, only if you insist on different threads having different working directories.

Yes I insist!  One obvious example is to have different threads traverse different directory trees concurrently.  With a per-thread current-directory this can be done easily without worrying about other threads interfering with the CWD:

  (define (for-each-file proc dir-or-file)

    (define (walk dir-or-file path)
      (let ((here (cons dir-or-file path)))
        (if (eq? (file-info-type (file-info dir-or-file #f)) 'directory)
            (parameterize ((current-directory dir-or-file))
              (for-each (lambda (x) (walk x here))
                        (directory-files)))
            (proc here))))

    (walk dir-or-file '()))

  (for-each-file (lambda (x) (write x) (newline)) "/usr/local/share")

So my point is that chdir should not be defined to have an effect on the interpretation of paths for open-input-file, directory-files, etc

Marc