Fork me on GitHub

@noisesmith maybe you can answer this. what would -main look like if you wanted to start a component and provide it to the repl and then stop the component when the repl exits? I couldn't find a decent example of this


ideally I would rather launch as java -jar the_app.jar


heh nvm, figured it out.

(defn -main [& args]
  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)
        {:keys [db-host db-name db-port user password]} options
        spec-mods {:subname (if (and db-host db-port db-name)
                              (format "//%s:%d/%s" db-host db-port db-name))
                   :user user
                   :password password}
        sys (component/start
             (create-sys (merge default-spec spec-mods)))]
    (repl :init (fn []
                  (println "initializing")
                  (in-ns '
                  (def sys sys)
                  (def user-name (:nav-user options))))
    (component/stop sys)))


Hi, is it a particularly bad idea to mix java and clojure in the same project? I mean that as every java application has structure: /src /main /clojure /java .... How can I import clojure class in java except add it to the dependencies as a jar file? Does anyone has such an experience?


You can try gen-class or proxy to port Clojure code to be callable from (Note I haven't used Clojure from Java)


Clojure and Java work pretty well together from the viewpoint of calling Java from Clojure


how do a square root in clojure?


is there a function for this?


Oh it's an actual dependency..


java.lang.Math/sqrt iirc


clojure does not generally provide wrapper functions for jdk methods that work well, fwiw


ok yea I was playing around with this I didn't think to drop to Java


HI all, fairly new to clojure and thus far have been using VS Code for writing clojure. It is ok but not ideal. I hear Emacs is where it is at for clojure but I’ve always been more of a Vim guy than Emacs. My question is…. Is Emacs definitively the best editor for Clojure or can I find a similar experience with Vim, Sublime, LightTable, etc? Thanks!


@fedreg: Cursive is excellent, Spacemacs is pretty good if you want a starter version of Emacs with Vim keybindings. Proto REPL for Atom is pretty popular too and it's even converted a few long time Emacs users over. I've tried all of them and spend most of my time in Cursive, and it was very easy to get started with as a Clojure beginner (at least compared with Emacs at the time)


@shaun-mahood Have never looked at Cursive. Will take a look! Thanks for the tip!


Also, @fedreg, I use Vim for all my Clojure dev and don't have any complaints with the ecosystem


yeah, vim with fireplace is pretty great if you prefer vim


@captainlexington @noisesmith any other packages other than fireplace that I should add to vim for clj?


I like vim-sexp - it’s like paredit but more natively vim flavored


also I have a gist with good ctags with clojure - looking it up…


this isn’t perfect, but it’s a lot better than the default (for exuberant ctags specifically)


Great, thx!


Although I want to check out vim-sexp now


@captainlexington yeah, I found that vim-sexp was more “vimmy” and less like a feature backported from emacs


(though I don’t like how it does some things with whitespace around non () brackets)


I will definitely snoop. Thx!


One thing I've encountered is one of my Clojure plugins overrides what constitutes a word solely for the command ciw


I have another plugin installed to user camel and snake case to detect word boundaries, which works great in non-Clojure files, and works for every movement except c in Clojure files as well


But I haven't done the work to figure out which plugin is causing it or how to resolve the conflict


hmm - either clojure-mode or vim-sexp sets a word to include ns prefix and dashes etc.


@captainlexington would you expect ciw and caw to do the same thing? or should ciw somehow get a “sub word” ?


@noisesmith That's a good point! I've long wanted a way to get both a case-delimited word and a whitespace-delimited worse with different movements


But I think it would be better to have something like w and W for that, for flexibility's sake


But W is probably already bound to something


it’s like w but doesn’t ignore punctuation etc.

braai engineer17:06:59

Am I the only one who has a hard time remembering the semantics of defmethod and defmulti?


nope, I always seem to relearn it

braai engineer17:06:08

I wish defmethod worked as I expected: first argument should be dispatch value, rest is everything else


first arg dispatch is defprotocol, i believe. defmulti dispatches however you like. that's the beauty of it.


you could dispatch on a global if you really wanted to.


just think of "defmulti" as "defdispatch", which is arguably a more accurate name.

Alex Miller (Clojure team)19:06:39

(defmulti m #(first %&))


@mobileink that’s not what he’s saying


he’s saying that he wants the method to have a different declaration syntax


haha, sorry misunderunderstood. but 1st arg to a defmethod is always dispatch-value, no?


yeah I’m not sure specifically what was meant there


maybe they misspoke and you accidentally understood them correctly 😄


to be fair, the docstring is not the pinnacle of clarity: (defmethod multifn dispatch-val & fn-tail). what is fn-tail?

Alex Miller (Clojure team)19:06:04

@mobileink yes, you could combine a macro’ed defmulti (like above) with a macro’ed defmethod to achieve “dispatch on first value” construct


does it include the dispatch-val? i don't recall, but the dispatch-val could be sth other than the actual args passed, no?


@alexmiller sorry, what do you mean by "macro'ed defmulti"?

Alex Miller (Clojure team)19:06:16

I meant: the request here is afaict to have a specialized defmulti that only dispatches on first value

Alex Miller (Clojure team)19:06:38

The cool thing about lisp is you can have all the specialized syntax you want

Alex Miller (Clojure team)19:06:50

by making a couple macros to give you that

Alex Miller (Clojure team)19:06:14

you could wrap defmulti in a macro that had the effective output above

Alex Miller (Clojure team)19:06:40

and you could wrap defmethod in a macro that simplified the syntax to assume a match on first value


yeah. (was this %& a typo or have i missed thg? ... #(first %&))

Alex Miller (Clojure team)19:06:34

( #(first %&) 1 2 3 ) ;; => 1


oy! the more i learn the less i know!

Alex Miller (Clojure team)19:06:08

no, you still know more, it’s just the boundary has moved farther out ;)


never heard of it. i'm appalled at my ignorance. where is this documented?


Clojure: The Language that Keeps You Humble.


oh, sure, in the main docs. that's hardly fair!


great news! but do please add an entry on %& for us bears of little brain.

Alex Miller (Clojure team)20:06:27

was not in the original article


for me it shows a result for % but not %&

Alex Miller (Clojure team)20:06:18

I don’t think it’s top-level but it’s in the guide. feel free to comment on the pr - it’s not done yet.


alexmiller: thanks to you and colleagues for all the great work you do. makes my brain tired to even think about how many balls you have to juggle. i'm just now trying to doc a smallish library and i may go insane before it's done. there's always one more thing.


Does anyone have a guide to make a simple HTTP server that accepts 1 POST and 1 GET endpoint with file upload? As simple and efficient as possible... Every single tutorial I've seen, does not work and I'm getting a little anxious about the ecosystem.


@eslachance lein new doesn't pull in the ring deps, deps are a per-project thing


@eslachance you would want to use a lein template that is meant for an http server with ring, like compojure or luminus


oh crap wait I forgot to CD into my folder. 2 secs


that still doens't help, that lein new command doesn't add ring deps


I swear I did this earlier with the same error but I in the folder


it has nothing to do with the folder