Fork me on GitHub

@borkdude Not sure if this helps any but in the node-based glob libs it would be * for any file in current directory and ** for recursion.


*.clj would look for any files as children in current directory where as **/*.clj would look for any clojure files in any subdirectory.


Another fs lib related question. I'm building a lib around java.nio but more clojure friendly. A lot of nio functions return java.nio.file.Path objects, but in Clojure I think we are more used to .File. For e.g. glob function, what would be the most convenient in Clojure world, a vector of Path or File?

Ben Sless06:01:45

Feels a bit like a protocol which can be extended to both types, no?


I have considered that but I don’t think it offers a benefit to return a custom type rather than some native type that is always coerced. Returning the custom type always means coercing return values which can be many


Coercing on input, not on output I mean. Pretty much what seq functions do

Ben Sless08:01:13

Returning a wrapped type is always an issue as writing a complete wrapper is a pain and it's less approachable to users, no? Why do you consider protocols a coercion?


Oh I mean returning a thing which implements that protocol but yeah, you can extend the protocol to the known type. But since there are only two, and doesn’t have to be extended I don’t see much benefit


Over just a function

Ben Sless08:01:30

"Just a function" is always a sane choice


both Path -> File and FIle -> Path are present in Paths (and as far as I know are cheap). But I think what clojure code would want is usually a File


I pushed an initial release of this lib to clojars: Test / review highly appreciated


There is an fs/file and fs/path to convert between the types

Alex Miller (Clojure team)13:01:49

It is a hard thing and I do not think there is an easy answer

Alex Miller (Clojure team)13:01:39

I have chosen to mostly focus on File entry points for functions in stuff I’ve done

Alex Miller (Clojure team)13:01:55

We have talked about extending with more Path support but I do not have a clear idea about how to do that cleanly


What I currently do: the resulting value can be fed into both a file and path function, which converts it to a Path or File and all API functions accept both


and maybe that is the only contract I should offer, the concrete return types shouldn't be important. if you need files, use (map fs/file ...).


I'm pretty surprised by how much I like after toying with it, so polished and nifty. More so compared to this other more popular project that felt all janky and slow and buggy.

👍 3