Fork me on GitHub
Timofey Sitnikov12:05:48

Hello Clojurians, do all of the :aliases function calls in deps.clj have to dispatch through -main via :main-opts, or is it possible to add a function in the namespace and call that function directly. I see that it is possible using lein something like;

{:aliases {"migrate"  ["run" "-m" "investtrack.scripts.migration/migrate"]
            "rollback" ["run" "-m" "investtrack.scripts.migration/rollback"]}}
Can something like that be done in deps.clj :aliases map? Or you just have to live with dispatching via a -main function?

Alex Miller (Clojure team)14:05:19

You can pass the name of a clj file to just load it and run the top level or use -e to evaluate an arbitrary expression

Alex Miller (Clojure team)14:05:56

The latter can be combined with requiring-reslolve to do what you want

Alex Miller (Clojure team)14:05:10

clj -e “((requiring-resolve ‘some-ns/some-fn) some-args)”

Alex Miller (Clojure team)15:05:03

You can put that in an alias but if you do, replace the spaces with commas in the expression (commas are white space but won’t get messed up by bash word splitting)


Hey all 👋 Begun learning Clojure last week……Starting off with the Brave book and a few 4clojure problems…..Wanting to contribute to #athens in a few weeks

👋 20
Adrian Smith19:05:50

any troubles let us know, athens seems like a really cool project


Awesome, thanks Adrian 🙂


Be careful if you use the Emacs setup it definites, it's quite out of date now. is an up to date guide for Clojure in Emacs. If you want a curated Emacs setup, then try Or there are several other editors you can use


Thanks @U05254DQM! I am currently using Cursive and have my VS Code set up with Calva

Cas Shun21:05:29

I need to utilize an InputStream to .read a number bytes, a fixed (large) number of times, to a clojure vector. I'm aware of a number of ways to do this, but I'm curious if there's a particular idiom and/or a method with the least overhead. I've been benchmarking various solutions and it's driving me crazy.


Don't read a byte at a time, use the arity that takes a buffer to fill


I am not sure exactly what you mean by reading bytes to a clojure vector


A clojure vector is not the most natural place to put individual bytes because of boxing. Depending on what is being done a nio bytebuffer or netty bytebuf can be very nice if mutable. There are some specialized versions of clojure vectors that avoid boxing

Cas Shun23:05:57

@hiredman which 'specialized versions of vectors'?


Look for gvec and vector-of


I have never used those


I have used various bytebuffer things a fair bit, and sometimes even used bitsets or byte arraya wrapped in bigintegers


It depends a lot on what you are ultimately doing with the bytes


You can also use randomaccessfile to memory map files, where those memory mapped views act like bytebuffers


(which may be the fastest way to get bytes from disk into memory, not sure)

Cas Shun23:05:37

ok, cool. This is more info than I had before

Cas Shun23:05:53

I wasn't aware of boxing as a concept at all, so that's going to be a good start 🙂


(actually you need a filechannel to map, which you can get a few places not just a randomaccessfile)


The jvm has some small number of built in types (called primitives) that are not reference types, and everything else is a reference type. So any kind of generic code will usually deal in reference types, which means the primitives need to get boxed (turned into instances of a reference type).


So for example the default way functions work in clojure is generic, which means it is defined in terms of a reference type, which means passing a primitive as an argument will box it.

Cas Shun23:05:44

I see, thanks. I'll research more about it