Fork me on GitHub
Rupert (All Street)16:02:11

There's a discussion about combining/separating namespaces in Clojure that may be

Matthew Twomey16:02:49

Yeah - I’m having a lengthly discussion with some of the same participants right now. If we can have load in babashka, we can avoid using potemkin and really just follow the pattern from clojure.core.

Rupert (All Street)16:02:42

clojure.core is basically the only namespace I've seen following that approach. Most end up having multiple namespaces.

Matthew Twomey16:02:20

Yeah, I just don’t like requiring so many namespaces. I’m really glad clojure core doesn’t also make me do that.

Rupert (All Street)16:02:43

Could your IDE help do it for you automatically? In Java every single class is imported from a different file - but IDEs handle it all for the user without them having to care.

Matthew Twomey16:02:45

Sure, it can be done with some emacs foo. I’d just rather avoid it all together. It seems like this is part of why load exists in the first place.

Rupert (All Street)16:02:31

It might actually be a nice additional feature for the clojure language which is some project level require definitions that apply to all namespaces automatically.

Matthew Twomey16:02:11

Yeah that’s true - like require my-namespace/* I’m sure there would be a very healthy debate about that though 🙂 What’s nice about the load / in-ns pattern is that it sort of “splits the difference”. You still need to be “explicit” - but you can get things combined into a single NS where you want to.

Rupert (All Street)16:02:32

Babashka has a function load-file but I don't think that's the same. You maybe be able to build on top of that though depending how it works.

Matthew Twomey16:02:11

Yes - the issue I ran into with load-file was this it’s relative to where executed from.

Matthew Twomey16:02:34

(otherwise it would have been fine indeed)

Rupert (All Street)16:02:58

You may be able to wrap around the load-file function - potentially even reading the file and generating modified temporary files that you load.

Rupert (All Street)16:02:46

It's possible that you can work out the relative path (.getAbsolutePath (.File. "."))

Matthew Twomey16:02:34

Ooh that’s true. Really though, solves this problem in a way that works with babashka. If I can use a core feature to replace potemkin though, I’d prefer that.

👍 2
Matthew Twomey16:02:29

If you ended up here, please see near the bottom of the linked thread. This turns out to be unnecessary and can be achieved by simply using in-ns in your “helper files”.