Fork me on GitHub
#clojure
<
2021-02-07
>
Charles Fourdrignier06:02:17

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 ?

seancorfield07:02:36

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

Charles Fourdrignier09:02:17

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

seancorfield19:02:17

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

seancorfield07:02:05

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

pez13:02:50

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! ❤️

kwladyka15:02:10

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" ""
                      "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_16:02:12

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_16:02:22

to me separate looks better but i dont know

phill17:02:09

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?

phill17:02:20

To clarify: The self-install reported it worked.

phill17:02:36

But a subsequent "lein" says NullPointerException.

phill17:02:00

Even "lein version" says NullPointerException.

phill17:02:10

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

phill17:02:12

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"

caumond17:02:06

@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.

takis_20:02:44

Thank you borkdude i am trying both now

takis_20:02:54

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

allenj1223:02:23

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]

borkdude23:02:36

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