This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-03
Channels
- # asami (2)
- # aws (2)
- # babashka (1)
- # beginners (26)
- # calva (5)
- # clj-kondo (1)
- # cljfx (10)
- # cljsrn (4)
- # clojure (56)
- # clojure-france (1)
- # clojurescript (4)
- # code-reviews (1)
- # conjure (9)
- # core-async (3)
- # defnpodcast (2)
- # depstar (9)
- # emacs (17)
- # fulcro (22)
- # graalvm (2)
- # graphql (10)
- # meander (6)
- # overtone (3)
- # rdf (1)
- # reitit (4)
- # shadow-cljs (32)
- # spacemacs (18)
- # sql (1)
- # vim (11)
- # xtdb (33)
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
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
@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)
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
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.
@andy.fingerhut cool thanks for the tip
@murtaza52 There was a similar question about this on SO recently: https://stackoverflow.com/questions/64077153/ns-unexpectedly-evaluate-to-user-namespace-using-lein-run-but-not-when-us/64077477#64077477
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?
Implemented over Clojure data: https://github.com/tonsky/datascript
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? http://www.multunus.com/blog/2016/11/building-sql-like-dsl-clojure-part-1/
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
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 clojure.java-time?
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.
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
^ 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
@will08rien At work we use a mixture of Java Time via interop and also clojure.java-time
-- the latter makes certain coercions and date arithmetic a lot "cleaner" (and easier to read) than plain interop.
Thanks Sean. I'll keep this in mind and try to make the decision on a case by case basis.
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?
Hi all, I have a really basic build/deploy question. In https://github.com/eamonnsullivan/github-pr-lib, 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 java.io.FileInputStream/open0 (FileInputStream.java:-2).
./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?