Fork me on GitHub
#off-topic
<
2021-01-30
>
jaide00:01:13

@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.

jaide00:01:54

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

borkdude13:01:14

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?

borkdude07:01:49

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

borkdude07:01:38

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?

borkdude08:01:12

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

borkdude08:01:37

Over just a function

Ben Sless08:01:30

"Just a function" is always a sane choice

noisesmith16:02:50

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

borkdude16:02:38

I pushed an initial release of this lib to clojars: https://babashka.org/fs Test / review highly appreciated

borkdude16:02:56

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 http://java.io with more Path support but I do not have a clear idea about how to do that cleanly

borkdude13:01:34

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

borkdude13:01:42

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 ...).

clyfe20:01:03

I'm pretty surprised by how much I like https://github.com/hlissner/doom-emacs 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.

6
👍 3