Fork me on GitHub

can anyone help me with a stupid git question? totally clojure unrelated


I forked a repository, made a commit and made a pull request on my fork


now i’m making sort a different commit so I want to be able to go back down to the origin branch to the original forked repository, make my commit, then make a separate pull request


(also keep in mind I’ve made the edits already to the branched repository…)


Do you have an origin setup?


it might be just doing git checkout origin/master -b new_branch and committing that new branch for PR


if you don't, then sub origin/master with the commit hash of where the original repo's HEAD


Yeah that helped, thanks


I now have a luminus project, with three cljc files I want to use in a different project. Does this mean, when I already ran the other project, just requiring the namespaces will be enough?


@gklijs I'd say that you need to ensure that the another project is on classpath, which typically means using something like lein install to install the other project jar to local maven repo and then add the appropriate require. You can also consider using "checkout dependencies":


Thanks, that looks usefull


Hello. I am looking for a clojure library that would JWK. The only thing I can find is that has some code to do so, but I can't find any dedicated library.


I've just started learning clojure-specs. My question is: what is the right place to put them? in a different file or right next to the production code?


Right next to.


If you put it to a single file, you'll have nasty conflicts in maps specs created with s/keys.


Sometimes you are forced to put them somewhere else, e.g. to cljc files when you share them between clojure and clojurescript.


Another case is some common spec building block that you use in multiple places. At that point it will be obvious that it needs to be placed in some 'common specs' ns.


so basically the best would be closed to the code, but if I have to share them so I have to use a different ns


Anyone willing to help me test something. I have a friend who is doing a comparison of how different languages handle clojures. I was hoping to help him out with converting this JS closure functionality into CLJ:

function doit() {
    var a = ["a", "b", "c"];
    var b = ["x", "y", "z"];
    var counter = 0;
    a.forEach(function(foo) {
        counter = 0;
        b.forEach(function(bar) {
            // print info
                counter: counter, 
                foo: foo, 
                bar: bar
I've started the definitions as:
(def a ["a" "b" "c"])
(def b ["x" "y" "z"])
(defn doit [] (
I'm a bit stumped as to what to do within the doit function though simple_smile


Would I approach it using two maps like this? (defn doit [] (map a (map b ( ... )))


I’m a bit surprised that this throws exception instead of catching it (try (do (ex-info "noooooooo!" {})) (catch Exception e (println “oopsie”)))


Is it supposed to work like that?


@yogidevbear those should be inside a let, I imagine scoping inside doit is important


@yogidevbear I am struggling to see how that JS is really a Closure? I guess doit contains the two arrays a and b so that's a closure but it's not a useful one.


Don't think I'm aiming for useful here, more just an observation of how clojures are treated in different languages


@dominicm yeah the a and b would have to be scoped to doit for it to be considered a closure. After that I'd use a for list comprehension to process b inside a


@agile_geek probably better to be a doseq, side effects & all 😛


Oh good point. Forget about the println


So more like

(defn doit [] (
  (let a ["a" "b" "c"])
  (let b ["x" "y" "z"])
  (doseq ...)))


(defn doit
   (let [a ["a" "b" "c"] b ["x" "y" "z"]]



(defn doit [] (
  (doseq [a ["a" "b" "c"]
          b ["x" "y" "z"]]


That doseq is the same as his nested forEach's


I should probably have added the output that I see from the JS example as a comparison:

VM128:11 Object {counter: 1, foo: "a", bar: "x"}
VM128:11 Object {counter: 2, foo: "a", bar: "y"}
VM128:11 Object {counter: 3, foo: "a", bar: "z"}
VM128:11 Object {counter: 1, foo: "b", bar: "x"}
VM128:11 Object {counter: 2, foo: "b", bar: "y"}
VM128:11 Object {counter: 3, foo: "b", bar: "z"}
VM128:11 Object {counter: 1, foo: "c", bar: "x"}
VM128:11 Object {counter: 2, foo: "c", bar: "y"}
VM128:11 Object {counter: 3, foo: "c", bar: "z"}


Go write him an example of how broken JS closures are:


(doseq [i (for [x (range 10)] 
                  (fn [] x))]
    (println (i))) 


prints 0-9 in Clojure, and prints 9 ten times on Python and JS


mutable closures FTL


@singen you are not throwing the exception. Your (ex-info ...) call is creating an exception that then falls out of the the try.


this is throwing the exception

    (throw (ex-info "noooooooo!" {}))
    (catch Exception e (println "oopsie")))


Ah, I need to throw ex-info, of course


Why is catch bad?! 😄


It's clojurebot complaining - it works in an ordinary repl


@yogidevbear my solution

(def as ["a" "b" "c"])
(def bs ["x" "y" "z"])

(for [a as
      [counter b] (map-indexed vector bs)]
  {:counter counter :foo a :bar b})


That's awesome! Thank you @tbaldridge :thumbsup:


Now to fully comprehend what you'd actually done 🙂


So (for [a as is doing a for-loop over as and assigning the current for-loop item to a yes?


The next line confuses me a little. [counter b] is creating counter and assigning it the value of b which is coming from the index of the current item position in the map of vector bs?


Am I understanding that correctly?


no, the map-index pairs each b with a number, then we use destructuring to assign the number to counter and the value to b


okay, was just reading docs on map-indexed


I think that makes sense


all the closures are hidden from you here behind the for macro. So you don't ever see them but they are there 🙂


This code doesn't print out the results, but returns them which is the more functional method anyways.


So (map-indexed vector bs) is generating something like [0 \x 1 \y 2 \z]


wait, no, it's [[0 "x"] [1 "y"] ...]


Sorry, yes 🙂


Is anyone familiar with ?? Long story short I want to use it to build an app but I'm a confused in regards to where my Clojure (aka desktop code) would go and how it would communicate with the ClojureScript/Electron UI code.


@mbcev Normally you don’t write Clojure code in an Electron app — your back end is node.js, and you use node/npm for all your requires and such


@manutter51 so I'm probably using the wrong tool for the job. What I'd like to do is have some clojure code that does some networking stuff and I thought it would be cool to use Electron as a nice front-end for that app. But perhaps my thinking of Electron and CLJS as a "View" for a Clojure "Controller" in a MVC type mindset is misguided. Yes?


I don’t think many people are trying to build stuff like that, in any case. You might be interested in looking for a JavaFX/Clojure lib, I think I saw one recently but never got around to playing with it.


On the other hand, if you don’t mind browsing the NPM archives, you can probably find Node equivalents for the networking stuff. You can still write your app code in ClojureScript, and just use interop to talk to the Node lib


I’ve done a little of that, and it’s fun 🙂


If I were doing my app the "traditional" (for me) way I'd probably use Java and Netty for the networking code but I kind of wanted to see what Aleph was all about and then I thought Electron looked interesting. But from what it sounds like maybe it would be easier to use JavaFX + Clojure rather than have the Clojure "server" code talk to the Electron "client" code right?


right - and cljs in electron can actually do all that networking stuff if you want to use electron


but the best options are clojure/javafx or cljs/electron rather than trying to mix them, for a simple app


Gotcha, gotcha. Thank you guys. Can you point me in the direction of some networking stuff with cljs?


also, don’t be afraid of interop - you can use the AJAX api directly from cljs code


or the extensive built in libraries that node provides

Drew Verlee17:03:44

I know that a clojure program can use a java library, is the reverse also true? Does it require anything?


drewverlee it’s pretty straightforward - it means using and clojure.lang.IFn


usually you need to use Clojure.var to find require, and calling that to make your ns load, then Clojure.var again to access the functions or values you need


in fact, if I were designing the next version of I would make require accessible directly without using var to find it


(not that anyone would let me do such a thing)

Drew Verlee18:03:20

I’m trying to find out if i can just make this library I need to create in Clojure, as the rest of the team is java, i figured i would do it in java. However sense i’m a java newbie, its becoming very painful as 60% of my mental energy is spent on boiler plate types.

Drew Verlee18:03:46

Also, i wanted to make it very extensible.


@drewverlee it might be simplest if you make a small java class that uses Clojure.var to load up and require your clojure functions, and then exposes a normal java interface


perhaps you could even get a java using coworker to define the interface, and a minimal class where you can fill in the implementation via Clojure.var, then do the rest of the work in regular clojure

Drew Verlee18:03:27

Yea, i’ll look into that. Thanks for the advice.


the guide on should be pretty straightforward to follow


also your clojure deps can be translated to a pom.xml, or you can implement your clojure lib in the normal way, and once that is in a maven repo the larger project can pull it in like any other maven dep


Does it make sense to define my own tagged literals in clojurescript? It seems like a neat way to design but it also looks less straightforward than in Clojure

Drew Verlee20:03:01

How does one pass a macro around like or? I felt like i knew how to do this and now i find myself confused about my options

Drew Verlee20:03:44

I just want to let the user choose between or or and


@drewverlee you pass functions that use or or and internally - macros are not first class