From: John Cowan <xxxxxx@ccil.org>Date: Tue, Sep 3, 2019 at 5:56 PMSo here's the generator:(define make-directory-files-generator(case-lambda((dir dot-files?) (make-directory-files-generator* dir dot-files?))((dir) (make-directory-files-generator* dir #f))))(define (make-directory-files-generator* dir dot-files?)(let ((dir-obj (open-directory dir dot-files?))(eof (eof-object)))(lambda ()(let ((f (read-directory dir-obj)))(if (eq? f eof) (close-directory dir-obj))f))))I haven't actually tested this, but it's at least conceptually correct.
After a finite generator has generated all its values, it will return an end-of-file object for all subsequent calls.
[ We're going to keep the "mostly harmless" directory-files. In prior discussions we liked directory-fold, but decided not to expose it. ]