Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 15:46 UTC)
(missing)
(missing)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 17:08 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 17:42 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 17:51 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:03 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:15 UTC)
Put directory-fold in the SRFI? hga@xxxxxx (29 Jul 2019 18:45 UTC)
Re: Put directory-fold in the SRFI? John Cowan (29 Jul 2019 19:38 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (29 Jul 2019 20:27 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 18:28 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:31 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 18:46 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:57 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 19:04 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 18:32 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:51 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 19:16 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (30 Jul 2019 18:52 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (30 Jul 2019 19:58 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (30 Jul 2019 20:44 UTC)
(missing)
make-directory-files-generator hga@xxxxxx (06 Sep 2019 16:21 UTC)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 17:26 UTC)
(missing)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 21:56 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:06 UTC)

Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 17:42 UTC

> (Added the list as CC:)

Thanks for keeping us in the loop (and sorry for being the resident
nitpicker).

>>         It's signature is:
>>
>>>         (directory-files/[dir dotfiles?]/)
>>
>>         Seems to me that /dir/ and /dotfiles?/ should be independent
>>         optional variables, if you specify a directory, you shouldn't
>>         have to also specify if you want to see the dot files.

A 'dotfiles?' argument is an interesting idea. I would personally leave
it out, but it's not a clear call.

- I would always leave out dot and dot-dot from the results (the two
directory entries that reference the current directory and the parent
directory, respectively). Those are not useful for anything - you know
that they always exist even without listing them. And to get info about
them, you need to call stat() anyway - readdir() can't be relied to
return any useful info about them. Also Python's os.listdir() has left
them out for probably more than a decade and it hasn't caused problems.

- For other dotfiles, I can see that it can be useful to leave them out.
However, sometimes you want them. And there are many other kinds of
files that are useful to leave out also - such as editor backup files,
binary files, empty files, non-regular files, etc. I would perhaps leave
dotfile to higher-level frameworks like 'glob'.

- A more general alternative would be a user-supplied filter procedure.
But that again gets into the territory of higher-level frameworks IMHO.

- Common Lisp used to have a 'with-directory-iterator' function in some
third-party library. So instead of returning a list of names, it
returned an iterable. For filtering, this could be the best option. A
directory _can_ in principle have 10k files or even more.

- Go's Readdir function takes an integer argument that gives the maximum
number of names to return. I think that's great, and it might make sense
for Scheme too. Personally I would rather have an optional max argument
than a dotfiles? argument, but this is not as black-and-white to me as
the exec-path-list thing - I can easily understand why you'd want a
'dotfiles?'.

- Continuing with the Go community, I tried to suggest that their "get
filename extension" function should have a special case for dotfiles, so
it doesn't think the whole filename is the extension. To my surprise,
they responded that they don't really believe in dotfiles and think
those are a hack. They didn't implement my proposal despite the fact
dotfile-sensitive behavior exists in Python's path extension function.

> Actually was thinking /[dir [dotfiles?]]/, not thinking that listing the
> current working directory is going to be super common, and a user can
> just put (working-directory) for /dir/ since we helpfully supply it.
> But I have no strong feelings against discriminating on type, besides it
> making the implementation significantly more complicated, since /[foo
> [bar]]/ is dead simple with Chibi Scheme's let-optionals ... which
> originally came from scsh....

If listing the current directory by default is from scsh, it's probably
for interactive use. When writing a script, I agree that it's not really
a useful shortcut, and can confuse more than help.

But interactive use is so different that I wouldn't make that a priority
for a general-purpose OS SRFI like this.