This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (5)
- # asami (7)
- # aws (10)
- # babashka (10)
- # beginners (49)
- # calva (12)
- # cider (5)
- # circleci (1)
- # clj-kondo (25)
- # clj-yaml (14)
- # clojars (5)
- # clojure (134)
- # clojure-europe (142)
- # clojure-france (3)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojurescript (10)
- # cursive (8)
- # datomic (19)
- # emacs (11)
- # fulcro (8)
- # graalvm (29)
- # honeysql (7)
- # jobs (4)
- # jobs-discuss (9)
- # lsp (196)
- # obb (4)
- # off-topic (40)
- # pathom (4)
- # releases (4)
- # remote-jobs (3)
- # shadow-cljs (16)
- # sql (25)
- # squint (2)
- # tools-deps (12)
- # xtdb (7)
- # yada (4)
Using Calva and VSCode, is it possible to require things in the REPL? I’ve tried
(:require my-projet.utils :as utils) but I get
; Syntax error (ClassNotFoundException)
:require keyword is part of the
ns declaration, that's what probably got you confused. I recommend reading up a little about namespaces and the REPL basics 🙂
FYI, there is nothing special about Calva's REPL. I know it can seem like that and you don't know how all these things compose. But regard Calva's REPL as if it is a regular Clojure REPL. That mental model will take you far. And when you are ready to challenge that model, then, well, then you will be ready. 😃
Oh, it is often worth including. There are some side effects to how the REPL is wired that can be involved in a particular problem. But it is also good to know that the regular Clojure reality applies. Calva connects to an nREPL server running in the same process as your application and the Clojure REPL. The nREPL server takes requests from Calva and uses the Clojure REPL to evaluate, then packages the results in a response and gives it to Calva. Meaning that the forms you evaluate using Calva will be evaluated by the Clojure REPL. Meaning that a syntax error like the one in the thread start, comes directly from the horse's mouth.
I should avoid putting anything in deps.edn's
:extra-paths that isn't meant to be evaluated?
Say I have some clojure files which I don't want to run, but just want to count the number of lines in them. Is it safe/make any sense to put those in
There are some tools (like tools.namespace) that may load all of the namespaces on the classpath, but whether that affects you depends on tooling
I found that if I include a particular Clojure repo in :extra-paths, unit tests which throw an exception stop working in my particular tooling setup :thinking_face:
Hard to explain without more info. I have seen someone here that ran into a similar issue due to use of tools.namespace but don't remember the details
I created an issue about it in the cider-nrepl repo and apparently in this case it does matter that there is "correct code" on the classpath. Just wanted to leave the link/details here in case anyone stumbles across it in the future. https://github.com/clojure-emacs/cider-nrepl/issues/760
Hi all. Trying to optimise this with threading but I can't because a string is not a function:
(Integer/parseInt ((request :query-params) "id"))
Tried optimizing it to this:
Before jumping in how to go about it, I would ask myself, critically, if a threading version would really be more readable. I doubt that personally. Can you explain what you dislike about your initial expression, and why you like to use threading here?
(macroexpand '(-> request :query-params "id" Integer/parseInt)) (. Integer parseInt ("id" (:query-params request)))
Use parentheses. The trick with leaving them out only works for a few built-in Clojure data literals since they implement IFn, i.e. not strings and Java methods.
What @U03BYUDJLJF said 👆
If it is just for an exercise, I like
macroexpand to show me what the threading macro is doing.
As of clojure 1.11 you can use
parse-long instead of
Integer/parseInt, which does behave better in a threading macro.
This ☝️ looks perfectly ok to me and I like it better than
(some-> request :query-params (get "id") parse-long)
(parse-long ((:query-params request) "id"))It tells you how to get the parameter "id" by listing the steps you have to do, in order, and doesn't throw an exception if query-params doesn't contain the key "id".
I want to replicate this behavior (ruby)
@data.xpath("//E1EDP01[not(ABGRU) or ABGRU = '99'][not(PSTYV = 'TATX')]") in clojure. So far I have
(xml-> xml :IDOC :E1EDP01) but I’m unsure how to do the
not statements. Does anyone know?
Oh, ok, I'm not familiar with the library but maybe you can use
Ok so this returns rows that has the ABGRU tag
(xml-> xml :IDOC :E1EDP01 [(tag= :ABGRU)])
I have two E1EDP01 blocks, one that includes the ABGRU tag and one that doesn’t. Sorry to say but the last piece doesn’t seem to yield the block without the tag, it returns an empty array
I don't know what's going on and this problem seems specific to that library, so maybe check out #xml .
(xml-> xml :IDOC :E1EDP01 (fn [loc] (and (or (some #(and (= :ABGRU (:tag (zip/node %))) (= "99" (text %))) (clojure.data.zip/children loc)) (not-any? #(= :ABGRU (:tag (zip/node %))) (clojure.data.zip/children loc))) (not-any? #(and (= :PSTYV (:tag (zip/node %))) (= "TATX" (text %))) (clojure.data.zip/children loc)))))
When using tools.cli, how do you tell Clojure that a parameter is supposed to be a string? My cli-options vector has this:
"--id-str ID" -- you have to provide a named placeholder for value-based options. See the example in the Quick Start https://github.com/clojure/tools.cli#quick-start where -p/--port is a value option and -v/-h are flag options.