[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] Ballot item #113 "directory contents"
- To: scheme-reports@x
- Subject: Re: [Scheme-reports] Ballot item #113 "directory contents"
- From: Alaric Snell-Pym <alaric@x>
- Date: Tue, 11 Jan 2011 14:53:37 +0000
- In-reply-to: <AANLkTi=THByNNJ=89=voRhLgrpj2vbWYuHEZdSC+AM46@mail.gmail.com>
- References: <firstname.lastname@example.org> <AANLkTi=THByNNJ=89=voRhLgrpj2vbWYuHEZdSC+AM46@mail.gmail.com>
On 01/11/11 14:36, Alex Shinn wrote:
> In particular, directory-files is in a sense more primitive than
> file-exists?, since the latter can be implemented (inefficiently)
> in terms of the former.
As I'm currently reading a book on algorithmic information theory, I
can't help but point out that given file-exists?, directory-files can be
written to (in finite time!) find all files with finite names by just
trying all possible strings into file-exists?... and if we know the
maximum filename length for our OS, we can even terminate in finite
time, having guaranteed to find all files ;-)
> Technically you could define directory? as:
> (define (directory? x) (file-exists? (string-append x "/.")))
> (modulo separator concerns), but the point is well taken.
> WG2 will include a full filesystem interface, and in WG1 we
> have to decide if we want to cherry pick any functions,
> include everything, or continue to be as useless as R5RS
> in this respect.
> One of the rationales in the first ballot pointed out that
> just adding file-exists? and delete-file was silly.
I agree... I voted to push the whole lot to WG2 (although I'm never
quite sure, in practice, what the difference between "wg2" and "no" is;
it's up to WG2 to make their own decisions as to what to include). I
think we should ignore the filesystem (other than as a shadowy place
that maps filenames to places where ports can go - which could just be a
static list of special device names in an embedded system - but the
structure of which is vague beyond that), or go the whole hog and
specify a proper filesystem interface, like java's File class or CL's
delightfully baroque pathname objects.
>> A secondary problem, which may indeed be considered well out of scope
>> for both WG1 and WG2 is that of:
>> - (portably) determining a directory entry separator character with
>> which to form a string to pass to open-directory (or directory-
>> files or whatever) when wishing to descend into said directory
Aye; my preference, rather than encouraging too much string arithmetic,
is to provide functions to convert lists of strings to and from paths in
the local convention (including mapping special relative-path
conventions like ".", "..", and a leading "/" as appropriate). But let
WG2 ponder on that. I'll be sure to follow their deliberations and bend
John's ear with my opinions in due course, should I see them straying
from the path of sanity ;-)
Scheme-reports mailing list