Fork me on GitHub

If I have a java class which has 2 methods get, one which returns a String, one which returns a byte array. How do I inform Clojure I'd like the byte array form?


What are the signatures of the two get methods besides the return values? That is, their number and types of parameters?


@andy.fingerhut Are differing args a prerequisite for this in java?


In this case, it is String vs byte array arguments too. I am curious to know if it was just get() if java return typing works


Overloaded methods in Java require having different arguments


Otherwise compiler can't guess what was meant to be called


In cases where the return is ignored, for example, or assigned to Object variable


Okay, cool. So I'll never run into that situation then! Great.


I have a ns in which I am declaring a bunch of vars (def a 1) (def b 2) is there a way I can get a list of all vars defined in a ns ?


@murtaza52 ns-publics or ns-interns, depends what you're after


There's a few other ns- functions too


@dominicm thanks, both of them are giving me the intended result, how do they differ ?


@murtaza52 ns-interns gives you all mappings, including private functions


thanks @schmee also is there a way to specify the current ns, trying to see if I can escape hardcoding the ns name when calling (ns-publics 'ns-name)


you can use *ns* as a shorthand for the current namespace


Is there a specific function I can use to map on a map and change its values?


no, you’ll have to use something like reduce-kv or Specter


I see almost everybody suggesting to write your own function such as


yeah, if you don’t want to use a lib for it then that is the way


All right, thanks!


is there a way to have private (def- ) just like private (defn- )


yes: (def ^{:private true} your-var), no shorthand for that one

👍 3

Since there’s only one element in the meta, there’s the tiny abbreviation of saying: (def ^:private your-var) But it’s not much


great thanks


so if I have *ns* in a fn, then it refers to the ns from which the fn is called.


One way to get the ns where the function is defined is to have something like (def my-ns *ns*) in the namespace where a function is defined, and use my-ns in the definition of that function.

👍 3

@andy.fingerhut cool thanks for the tip


@borkdude thanks will check it out


Is there a library that lets me run SQL over a vector of maps?


You mean the function "for"? I have a use case where I need to allow other non Clojure programmers to define selections over maps. So I wondered if someone implemented some SQL engine over standard vector of maps or such thing?


Datalog perhaps?


I thought about it, but I feel asking non Clojure devs to learn datalog isn't that much better then asking them to learn how to map/filter in Clojure itself. Which is what I have now, just take some Clojure code.


I admit, having a SQL JDBC driver that works on named collections of hash maps is quite appealing 🙂


This might be a good starting point if you want to build a DSL for them to use?


Hey guys, I'm using the java-time api. If I do something like (def now (local-date)) (println now) it prints #object[java.time.LocalDate 0x153739a 2020-10-03] how could I make it so it only prints the date? I've tried many things along the lines of (println (. java.time.LocalDate now)) with no success


(str (java.time.LocalDate/now))


Damn, that easy. Thank you so much. Was stuck for way longer than Id like to admit.


Out of interest is there a reason to use java time direct over and above


The reason Im using it is simply because it was the first thing that google brought up when dealing with dates. Its a throw away project so I didnt look to deep into it.

👍 3

I’d flip it around: is there a reason to use over java.time? 🙂


java.time is actually a legit good API, and it’s also compatible with Clojure by default since it’s immutable classes all the way

Darin Douglass19:10:28

^ I second this. We just interop with java.time directly. My only gripe is the the inst reader macro is actually a java.util.Date and not an Instant (which I get for back-compat/historical reasons)


Thanks for these perspectives. The rationale on the clojure-time page seems reasonable, is it in general only used in edge cases then (I appreciate this is a question that probably belongs in #beginners, but I loiter here too and obviously this came up ...)


it’s a matter of taste I think, some people prefer to avoid interop, I prefer to not use libraries that “just” wrap a Java library unless it provides substantial benefits over using library directly, such as providing some data- or macrodriven abstraction over a heavy OOP / imperative API


in the case of java.time, IMO a wrapper lib is not warranted since the library is so easy to use via interop already

👍 3

Thanks again!


@will08rien At work we use a mixture of Java Time via interop and also -- the latter makes certain coercions and date arithmetic a lot "cleaner" (and easier to read) than plain interop.

👍 3

Thanks Sean. I'll keep this in mind and try to make the decision on a case by case basis.

replied to a thread:For

You mean the function "for"? I have a use case where I need to allow other non Clojure programmers to define selections over maps. So I wondered if someone implemented some SQL engine over standard vector of maps or such thing?

Eamonn Sullivan23:10:44

Hi all, I have a really basic build/deploy question. In, I have a simple little lib that uses the Github GraphQL API to create/modify/merge pull requests. It all worked fine until I had the bright idea to move the GraphQL queries and mutations into separate files and slurp them in to the source code like

(def get-repo-id-query (slurp "./src/eamonnsullivan/graphql/get-repo-id-query.graphql"))
Now, everything works fine locally, but not when I build and deploy the library.
Execution error (FileNotFoundException) at (
./src/eamonnsullivan/graphql/get-repo-id-query.graphql (No such file or directory)
What is the correct way to include resources like this in a build and how do I refer to them in the source code?