Fork me on GitHub

make a jar, run plugins that lint or reformat code, deploy to an artifact cache or repo


run nrepl without adding nrepl code to your project


Right. However, those are, relatively speaking, painless to setup on your own (this is a subjective point) and the benefit of doing so is its very clear (if done well) how everything is working. As in, no black box. Would this be a valid statement?


I don't know of a linter that works without a lein or boot project


there might be a standalone program that makes a jar for a deps.edn project, but if it exists it is not widely used


ditto for deployment


once you make all of those things easy to do, you run into all the same design decisions that turn leiningen and boot into big slow programs, there's no simple fix for this


Agreed. It can become large. I think that, if this is unavoidable, the benefit might be that everything becomes a library that could be run without the need for a third party tool like lein.


kind of like what figwheel.main is doing now


:thinking_face: seems like eastwood would be easy to run with a deps.edn alias and maybe a few lines of code


perhaps - but this work would need to be repeated for each project that uses it, or you package it as a ready to go thing and end up in the same situation you have using these things with lein or boot


How to understand the Clojure function arguments destructuring. Who can explain this in more detailed?


there are any fork of 4clojure being maintained?


@stardiviner That is some very confusing code!


It says retain can take zero or more arguments. The id in the if-let shadows the id binding in the argument list (bad). args is just bound to the sequence of arguments passed in (which might be empty or...).


@seancorfield This code is copied (partly) from book <programming Clojure>. So this :as args is the whole passed in arguments of function retain like (retain 1 2) which args will be ([1 2])? and function retain can be no arguments or if have, then is destructued into [url id]. Then it will be url -> 1, id -> 2 ? I make an simple demo, like this, figured it out:

(defn parse-args-test
        [& [url id :as args]]
        (println (format "args: %s, url: %s, id: %s" args url id)))


args would be bound to (1 2) (not ([1 2]))


(retain 1 2) => url : 1, id : 2, args : (1 2)


Yeah, I also tried other arguments like (parse-args-test [1 2 3]). then args is bound to ([1 2 3]). Seems the whole argumeents is bound to args, and also arguments is destructed into url and id. I misunderstand that id :as args is kind of args is alias of id.


:as name binds all the stuff in it to name


Is there a way to find out how it is implemented in Clojure internal?


The actual binding shouldn't be rocket science, but it would be cool to understand how the destruction is carried out!


destructuring is done in macros by using the destructure function, like so:

=> (destructure '[[& [url id :as args]] [1 2 3]])
[vec__2429 [1 2 3] seq__2430 (clojure.core/seq vec__2429) vec__2432 seq__2430 url (clojure.core/nth vec__2432 0 nil) id (clojure.core/nth vec__2432 1 nil) args vec__2432]

metal 8

Thanks, that's great I can dig deeper to know it.


not sure if this is the right place to ask question but here it goes. Are there any libs for cljs for using google maps that are up-to-date ?or any other map that has direction for that matter, yandex is ok too i found 2 updated 2013/2015 that seems outdated

new clojure student20:08:53

Is there an answer key somewhere? I'm stuck on this problem. I can't figure out the right syntax and there aren't many clues.


Do you know java? The difference between a class and an instance?


That's tough because it's not really a clojure problem, more about interop with the host


One correct answer looks like this. Create an instance of the URL class, then slurp from its openStream method.


The syntax in the question is attempting to call a static or class method on the URL class. The distinction, if one doesn't know java or other OO languages, is definitely not obvious.


Hrm. That's an odd problem, given that you can just (slurp "") But, perhaps it is attempting to explore interop a bit.


(`slurp` is a function that takes an HTTP URL as a string and returns the content as a string)


Ahh, I see. The problem itself states this 🙂


Yeah, looks like it's in a section about interop. Eh, would think it would be better to demonstrate interop for cases where there isn't already an idiom.

Bobbi Towers20:08:56

Is there an easy way to do that in cljs, where we don't have slurp?


The way to do it would depend on which JavaScript environment your ClojureScript is running in.

Bobbi Towers20:08:47

I was thinking of a web app that would take a URL and parse it to only render relevant sections or something


With ClojureScript running in a browser that has the fetch API you could grab stuff asynchronously. With the shipping REPL (avoiding CORS), here is an example:

$ clj -m cljs.main
ClojureScript 1.10.339
cljs.user=> (-> (js/fetch "") (.then #(.text %)) (.then prn))
#object[Promise [object Promise]]
cljs.user=> "<!DOCTYPE html> (elided html) </html>"

👍 4
Bobbi Towers21:08:32

Thanks! That was a random lurking question that I couldn't find the answer to because it was too simple.

Jp Soares22:08:06

How should I go for a map with an option key? Should it have the key with an empty value or should I create the key in the map when it's necessary?


@jpsoares106 I think both ways are common, but I’d say I think the approach of treating a missing entry as representing a default is more frequent (and arguably more flexible)

Alex Miller (Clojure team)22:08:44

absent is strongly preferable to nil


Could someone clever, please, explain to me why (->> 1 #(mod % 12)) seemingly returns a function?


I do understand why adding extra parens woks, but do not see why it doesn't work as I expected without them.


On a more interesting note, when I switch to ->, I get an exception java.lang.Long cannot be cast to clojure.lang.ISeq.


I've figured it out using macroexpand, sorry for the inconvenience (I'm not that used to macro heavy languages)


(macroexpand '(-> 1 #(mod % 12))) check what this returns


but the story is that -> blindly puts things into lists. it's not aware of invocation or anything semantic. All it is doing is putting things into lists


@dpsutton it's a good reminder, thank you. I keep forgetting that lisps have an incredibly simple evaluation model