clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2021-02-07T06:44:17.278300Z

I would like to store a var (as a string) , then get it back as a var. Right now, I'm here.

(var-get (eval (read-string var-as-string)))
Is there a better/more idiomatic way to do this ? This imply some security concerns. I could probably check that the result of read-string is a var in the expected namespace. Do you see something something else ?

seancorfield 2021-02-07T07:01:36.279Z

You say "Var" but do you really mean "qualified symbol", e.g., foo.bar/quux?

2021-02-07T09:15:17.281400Z

Yes, I hesitated on the case. 🙂 Thank you for the solution.

seancorfield 2021-02-07T19:08:17.307200Z

In general, if you find yourself reaching for eval, there's probably a better solution 🙂

seancorfield 2021-02-07T07:03:05.280100Z

(requiring-resolve (symbol sym-as-sring)) would give you access to the value, including requiring/loading the namespace if necessary.

2021-02-07T09:15:17.281400Z

Yes, I hesitated on the case. 🙂 Thank you for the solution.

pez 2021-02-07T13:01:50.286400Z

Hello, Clojure experts. I need some help figuring when Calva Paredit should drag sexpressions in pairs. (Currently you can only https://calva.io/paredit/#editing, but in places like maps and let boxes it makes sense to drag by pairs. In this issue, there’s a gif showing my current dev version handling the key/value pairs in maps: https://github.com/BetterThanTomorrow/calva/issues/529 Hoping the reply thread to this post can collect me some ideas, wishes and “don’t forget about”. Thanks in advance! ❤️

kwladyka 2021-02-07T15:41:10.290200Z

clojure.tools.logging (l/info "response\n" (pr-str response)) I use JUL and the issue is (.getMessage record) is private String message;. I want to do (l/info {:foo 1} "response\n" (pr-str response)) or even use meta, but in log formatter I can’t read this, because I have this as string. Any way to pass different data, than string to formatter? Based on data I need to generate different data structure for log, which is structured to JSON. So now I have {"severity":"INFO","logger-name":"api.logs.google-json-payload","message":"{:a 1} bar"}, but I want to use this {:a 1} to determine what structure I need to generate. In some cases I need to add to JSON data like this, but I have to know when and I have to pass this data to formatter not as a string:

{"httpRequest" {"requestMethod" "POST"
                      "requestUrl" "<http://example.com/some/info?color=red>"
                      "status" 400
                      "remoteIp" "111.222.333.444"
                      "latency" "3.5s"}}
This is quite complex topic itself to talk about this on slack 🙂 For exception I could use ex-info, but how to do it for normal logs?

takis_ 2021-02-07T16:31:12.299200Z

Hello , when i want to use Clojure from java, with java as "parent" application,what is the prefered way? uberjar clojure with lein and use it from Java maven project? or mix Clojure and Java into a maven project without lein use?

takis_ 2021-02-07T16:33:22.300300Z

to me separate looks better but i dont know

borkdude 2021-02-07T16:53:54.301200Z

@takis_ Probably the latter and then use the clojure java API https://clojure.github.io/clojure/javadoc/clojure/java/api/package-summary.html

2021-02-07T17:06:09.302200Z

I downloaded lein.bat but when I run it I get NullPointerException. ... Is it supposed to work? If so, how would you suggest I troubleshoot?

2021-02-07T17:06:20.302500Z

To clarify: The self-install reported it worked.

2021-02-07T17:06:36.302800Z

But a subsequent "lein" says NullPointerException.

2021-02-07T17:07:00.303100Z

Even "lein version" says NullPointerException.

2021-02-07T17:07:10.303400Z

I do not have a project.clj or any profiles on this machine yet.

2021-02-07T17:09:12.304300Z

If I cd to my home directory before I run "lein", then I get "ExceptionInInitializerError", blah blah, "Caused by NullPointerException" and all the stack frame start with either "java.base" or "clojure"

caumond 2021-02-07T17:18:06.306900Z

@phill, you have a specific #leiningen channel for leiningen based question. The #beginners section is there also for that kind of questions (,p. That said, it is suppose to work. Leiningen is ok, and I started there. But as a beginner, https://clojure.org/guides/deps_and_cli is maybe more "vanilla", and more easy to start with.

seancorfield 2021-02-07T19:08:17.307200Z

In general, if you find yourself reaching for eval, there's probably a better solution 🙂

takis_ 2021-02-07T20:54:44.308300Z

Thank you borkdude i am trying both now

takis_ 2021-02-07T20:56:54.310200Z

and both are easy to use actually , at least for the simple things i do so far

allenj12 2021-02-07T23:17:23.311800Z

has anyone tried to use re-matcher or re-groups recently? I can use things like re-find just fine but when I use re-matcher etc.. I get

#object[TypeError TypeError: Cannot read property 'call' of undefined]

borkdude 2021-02-07T23:20:36.312400Z

@joeallen92 it looks like you are in CLJS? re-matcher doesn't exist in CLJS

allenj12 2021-02-07T23:22:05.312600Z

oooo ty