This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-12
Channels
- # beginners (81)
- # boot (29)
- # cider (7)
- # cljs-dev (147)
- # cljsrn (5)
- # clojure (121)
- # clojure-austin (4)
- # clojure-conj (4)
- # clojure-italy (9)
- # clojure-russia (20)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (34)
- # clojurescript (137)
- # cryogen (2)
- # cursive (1)
- # data-science (1)
- # datomic (29)
- # events (9)
- # figwheel (1)
- # hoplon (14)
- # jobs (2)
- # luminus (2)
- # off-topic (7)
- # om (36)
- # onyx (6)
- # parinfer (14)
- # re-frame (13)
- # reagent (74)
- # specter (2)
- # test-check (1)
- # untangled (43)
- # vim (14)
- # yada (36)
@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 https://clojure.github.io/clojure/clojure.main-api.html#clojure.main/repl
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 'com.cordatahealth.run)
(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
@spinningtopsofdoom Thanks!
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 https://github.com/clojure/math.numeric-tower
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) https://gist.github.com/noisesmith/ebe8b3f185e34a7de04b1189b21ba59b
Feel free to snoop my vimrc: https://github.com/CaptainLexington/dotfiles/blob/master/vimrc
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)
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.
Am I the only one who has a hard time remembering the semantics of defmethod
and defmulti
?
nope, I always seem to relearn it
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.
(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
?
@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"?
I meant: the request here is afaict to have a specialized defmulti that only dispatches on first value
The cool thing about lisp is you can have all the specialized syntax you want
by making a couple macros to give you that
you could wrap defmulti in a macro that had the effective output above
and you could wrap defmethod in a macro that simplified the syntax to assume a match on first value
variadic anonymous arg
( #(first %&) 1 2 3 ) ;; => 1
no, you still know more, it’s just the boundary has moved farther out ;)
we have a guide coming that’s a more symbol indexed https://github.com/clojure/clojure-site/pull/184
it’s in there
was not in the original article
for me it shows a result for % but not %&
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