I wrote this lib/std/private/globs.nim some time ago for use in kochdocs; this RFC is to move it to stdlib inside os.nim or a new std/globs.nim
design rationale
only a follow filter is needed; user code can without loss of generality filter the iterator output so we don't need a yieldFilter (as done in pkg/glob (/cc @citycide see http://bolingen.me/glob/latest/glob.html) or even a selection for pcFile, pcDir etc (as done in os.walkDirRec): this can all be done in client code (unlike what's done in follow filter since it'd be "too late").
walkDirRec can be re-written by calling walkDirRecFilter (and could be deprecated maybe)
in future work I want to allow adding a sortBy = cmp (by a user defined unary or binary cmp proc); this could be done by doing a bit of refactoring by adding std/sorts so that os can import std/sorts and std/algorithm can import std/sorts, to avoid too much dependencies in std/os
alternative is to move walkDirRecFilter to a new module std/globs ; it might be better but that would prevent de-duping walkDirRec
proposal
I wrote this
lib/std/private/globs.nim
some time ago for use in kochdocs; this RFC is to move it to stdlib inside os.nim or a newstd/globs.nim
design rationale
yieldFilter
(as done in pkg/glob (/cc @citycide see http://bolingen.me/glob/latest/glob.html) or even a selection for pcFile, pcDir etc (as done inos.walkDirRec
): this can all be done in client code (unlike what's done infollow
filter since it'd be "too late").walkDirRec
can be re-written by callingwalkDirRecFilter
(and could be deprecated maybe)discussion
s/walkDirRecFilter/glob
?sortBy = cmp
(by a user defined unary or binarycmp
proc); this could be done by doing a bit of refactoring by adding std/sorts so that os canimport std/sorts
and std/algorithm canimport std/sorts
, to avoid too much dependencies in std/oswalkDirRecFilter
to a new modulestd/globs
; it might be better but that would prevent de-dupingwalkDirRec
fusion/globs
but that requires accepting https://github.com/nim-lang/fusion/issues/22 so that kochdocs canimport fusion/globs